In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Python mobile phone and computer game script writing method, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
Preface
Hello, everyone. My name is Sun Nian. I found that the number of my fans is rising very slowly, and this time I have to pay attention to my thick skin. This time is a small game script, in essence, it can be used in any computer and mobile games.
Analysis (x0)
This game is "Don't guess a hundred dollars" on 4399, which means let's just step on the black block and then play us first-hand music.
Let's take a look at the classic mode and choose pro, although I don't know the difference between the various modes, so I just chose one at random.
This discerning person can see that it is possible to click on the black block as much as possible in a certain period of time.
You can see that it's all black at the beginning of the click. I'll try to click on it.
You can see that when we click start, the black block moves down one grid and turns gray, and then the black block on the top automatically falls down.
So does that mean we always just need to click on the black box in the penultimate row?
Analysis (x1)
Then we just need to select the black block within a certain range of pixels (that is, in the red box) to click on it!
So how to determine this pixel range?
In fact, we only need to determine the pixels in the upper left corner of the red box, because the size of the box in the game is constant, and then let the Abscissa + 4 square width, ordinate plus the height of the square.
So how to tell which block is black?
We all know that colors are made up of RGBA, and red,green,blue,An is transparency. Use any screenshot tool such as QQ, ctrl+A screenshot to put the mouse over the black box to see the value of RGB, in my case is (2jin2jin2), each computer may be different, a little chromatic aberration is normal. The closer to 0 means the darker the color.
So big brother black block how to judge? In fact, we just need to take the central point of each square! In front of us, we have taken the pixels in the upper left corner of the red box, and the size of the square is the same, so if we manually take the length and width of the square, then the center point of each square can be easily calculated!
Video tutorial
Two video tutorials are provided here, one is the video of this article, and the other is the video of mobile games.
Call me a bad person? Well, let the Python script play the game instead of me!
I heard that someone on the market is selling it for money? Use Python to make Douyin fully automated multi-function script!
Source code import pyautogui # Automation Keymouse relies on import timepyautogui.FAILSAFE = True # safe mode to open the mouse to the upper left corner of the termination program time.sleep (3) # delay three seconds to start while True: rect = (0, 0, 1920, 1080) # screen size photo = pyautogui.screenshot (region=rect) # photo.save ('1.png') # Test for i in range (615,950) 100): # coordinate self-test result = photo.getpixel ((I, 652)) # tested RGB if result [0] = = 2: pyautogui.click (I, 652) about pyautogui installation 1, download and install
Web site:
Https://pypi.org/project/PyAutoGUI
Click Download files to download the PyAutoGUI-0.9.38.tar.gz on the right
After decompression, go to the decompression directory and execute python setup.py install
According to this method, it was successfully installed on my computer.
2. Check whether the installation is successful
Enter Python and execute:
Import pyautogui
After reading the above, have you mastered how to write scripts for Python mobile phones and computer games? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.