Use Python to create a hop assistant and python Production Assistant
1. Preface
I believe everyone is familiar with the jump, and now all kinds of plug-ins and auxiliary services are also full of flying, it is no surprise that my friends ranking is 800 or 900. A certain treasure searches for a bunch of results, and the lowest is actually as long as there are more than three pieces. If you want to brush more than a few points, it's really outrageous.
As a programmer, I am determined to do it myself. Nothing else. In order to hone my ability to solve problems, I also want to entertain myself. For such tasks, the most suitable is Python, a rich third-party library, and has the characteristics of the glue language.
The main design idea of this program is, on the PC end, adb connects to the mobile phone → screenshot → display on the PC end → select the start and end points with the user's mouse → calculate the distance and duration → simulate the press on the adb sending command → screenshot loop.
2. ADB
Adb: Android Debug Bridge, which consists of the following parts:
• The Client is running on the development machine, that is, your development PC, used to send the adb command
• The Deamon daemon is running on the debugging device, that is, the debugging mobile phone or simulator.
• Server, as a background process running on the development machine, that is, your development PC, is used to manage the communication between the Client and the Deamon of the mobile phone in the PC
The adb command we usually use refers to the Client program. The Server actually listens on port 5037 on the local machine and forwards commands to the Deamon process of the mobile device through USB cable/wifi.
Adb command readers can go to the official website to view the document (http://adbshell.com/commands), here only describes the several commands used.
(1) adb devices lists all connected Simulators/devices
Prints a list of all attached emulator/deviceadb devicesIn response, return serial number and statee4b25377 deviceemulator-5554 device
(2) screenshot of adb shell screencap
Taking a screenshot of a device display. adb shell screencap <filename> adb shell screencap/sdcard/screen.png download the file from the device to the local machine. Adb pull/sdcard/screen.png
(3) adb shell input swipe simulate the sliding operation (long press)
Adb shell input swipe 100 100 100 100 simulation length by coordinate (500) length 100,100 ms C: \ Documents and Settings \ Administrator> adb shell root @ NX403A:/# input Usage: input [<source>] <command> [<arg>...] the sources are: trackball joystick touchnavigation mouse keyboard gamepad touchpad dpad stylus touchscreen The commands and default sources are: text <string> (Default: touchscreen) keyevent [-- longpress] <key code number or name>... (Default: keyboard) tap <x> <y> (Default: touchscreen) swipe <x1> <y1> <x2> <y2> [duration (MS)] (Default: touchscreen) press (Default: trackball) roll <dx> <dy> (Default: trackball)
Well, the above are the adb knowledge points required for this time.
3. Python
(1) Call the command line
Python has multiple methods to call command lines, which are commonly used in OS. system (cmd) and OS. popen (cmd) and commands. getoutput (cmd), the main difference between the three lies in the acquisition of the return value. The first one cannot obtain the return value, and the second and third one can be obtained. Which one can be used here, because the return value is not required.
(2) OpenCV
We mainly use OpenCV for image scaling and other operations. PIL can also be used.
(3) Tkinter
The buttons and PhotoImage widgets are mainly used. Not much.
The implementation of the program is very simple. The Code will not be disclosed for some reason, but it is mainly a process of fine-tuning parameters.
Program:
The next step is to use OpenCV and neural networks to automatically identify and calculate the distance.
I solemnly declare that this article is only used for study and entertainment. Do not spread it at will.