Hop-Hop Accessibility tool
Preparation Tools
- ADB driver
- Android phone
- Turn on the phone's debug mode
- USB access to your phone and computer.
Pycharm: The only one by one in the universe dedicated to Python development IDE tools
Implementation principle:
- Get the phone's real-time
- Click Start position and landing position
- The distance between the two points of the technical calculation
- Calculate Press Time
- Send a press Order
- Refresh your phone again
Implementation code:
ImportOSImportPil,numpyImportMatplotlib.pylab as Plt fromMatplotlib.animationImportfuncanimationImporttimeneed_update=Truedefget_screen_image (): Os.system ('adb shell screencap-p/sdcard/screen.png')#get the current interface of the phoneOs.system ('adb pull/sdcard/screen.png')#download current folder to current computer returnNumpy.array (PIL. Image.open ('Screen.png'))#Open the picture under the current filedefJump_to_next (Point1,point2):#calculate the length of the chordx1, y1 = point1; x2, y2 =Point2 Distance= ((x2-x1) **2 + (y2-y1) **2) **0.5Os.system ('adb shell input swipe 340 490 340 490 {}'. Format (int (distance*1))) #cell phone's click position, 0 0 0 0 0, XY axis Click Time after x-axis y-axis slidingdefOn_calck (event, coor=[]):#Mouse-bound click events [(x, Y) (X2,y2)], Globalneed_update coor.append (Event.xdata, Event.ydata)ifLen (coor) = = 2: Jump_to_next (Coor.pop (), Coor.pop ()) Need_update=TruedefUpdate_screen (frame):#update picture/Picture from picture Globalneed_updateifNeed_update:time.sleep (1) Axes_image.set_array (Get_screen_image ()) Need_update=Falsereturnaxes_image,figure= Plt.figure ()#Create a blank picture object, create a pictureAxes_image = Plt.imshow (Get_screen_image (), animated=true)#draw the captured picture on the axisFigure.canvas.mpl_connect ('button_press_event', On_calck) ANI= Funcanimation (figure, Update_screen, interval=50, blit=True) plt.show ()
Details:
Https://github.com/wangshub/wechat_jump_game
Python hop-on assisted learning