跳一跳python辅助程序

import os
import PIL,numpy
import matplotlib.pyplot as plt
import time
from matplotlib.animation import FuncAnimation
need_update=True

def get_screen_image():
    os.system('adb shell screencap -p /sdcard/screen.png')#获取手机当前截面截图
    os.system('adb pull /sdcard/screen.png') #下载当前截图到当前文件夹
    return numpy.array(PIL.Image.open('screen.png')) #返回图片像素数组

def jump_to_next(point1,point2):
    x1,y1=point1
    x2,y2=point2
    distance=((x2-x1)**2+(y2-y1)**2)**0.5
    #os.system('adb shell input swipe 320 410 320 410{}'.format(int(distance*1.35)))  #按压操作时间
    os.system('adb shell input swipe 320 410 320 410 {}'.format(
        int(distance * 1.35)))




def on_clock(event,coor=[]):
    coor.append((event.xdata,event.ydata))
    if(len(coor)==2):
        jump_to_next(coor.pop(),coor.pop())
    global need_update
    need_update = True

def update_screen(frame):  #跟新图片
    global need_update
    if(need_update):
        time.sleep(1)
        axes_image.set_array(get_screen_image())
        need_update=False
    return axes_image,





get_screen_image()
figure =plt.figure()
axes_image =plt.imshow(get_screen_image(),animated=True)  #把获取的图片画在坐标轴上
figure.canvas.mpl_connect('button_press_event',on_clock)
ani=FuncAnimation(figure,update_screen,interval=50,blit=True)
plt.show()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值