Python skip-assisted learning and python skip-assisted learning
Hop auxiliary tool
Prepare tools
- Adb driver
- Android phone
- Turn on the debugging mode of the mobile phone
- Connect your phone and computer with usb
PyCharm: The only IDE tool dedicated to Python development in the universe
Implementation principle:
- Get real-time mobile phone
- Click Start location and landing location
- Distance between two points
- Computation press time
- Send the pressing command
- Refresh the phone
Implementation Code:
Import osimport PIL, numpyimport matplotlib. pylab as pltfrom matplotlib. animation import FuncAnimationimport timeneed_update = Truedef get_screen_image (): OS. system ('adb shell screencap-p/sdcard/screen.png ') # obtain the mobile phone OS on the current page. system ('adb pull/sdcard/screen.png ') # download return numpy.array(PIL.Image.open('screen.png') to the current computer folder) # Open the image def jump_to_next (point1, point2) in the current file ): # Calculate the string length x1, y1 = point1; x2, y2 = point2 distance = (x2-x1) ** 2 + (y2-y1) ** 2) ** 0.5 OS. system ('adb shell input swipe 340 490 340 490 {}'. format (int (distance * 1) # The mobile phone's click position, 0 0 0 0 0, X axis Y axis slide after the xy axis Click Time def on_calck (event, coor = []): # Click Event bound to the mouse [(x, y) (x2, y2)], global need_update coor. append (event. xdata, event. ydata) if len (coor) = 2: jump_to_next (coor. pop (), coor. pop () need_update = Truedef update_screen (frame): # update image/Slave image global need_update if need_update: time. sleep (1) axes_image.set_array (get_screen_image () need_update = False return axes_image, figure = plt. figure () # create a blank image object and an image axes_image = plt. imshow (get_screen_image (), animated = True) # Draw the obtained image on the coordinate axis and figure it. canvas. mpl_connect ('button _ press_event ', on_calck) ani = FuncAnimation (figure, update_screen, interval = 50, bval = True) plt. show ()
Details:
Https://github.com/wangshub/wechat_jump_game