Python hop-on assisted learning

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.