Python skip-assisted learning and python skip-assisted learning

Source: Internet
Author: User

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

Related Article

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.