用Python写一个微信跳一跳物理外挂(安卓手机版)
3、算出按压时间一个像素点的按压时间是1.35ms
4、再通过adb发送按压时间的命令
adb驱动很重要,需要先在cmd中运行adb驱动程序。
具体adb工具及及代码地址:http://download..net/download/sinat_37921768/10192092
注意:判断是否发送按压命令要确认获取到两个点后,并在发送按压时间后把上一次的数据清空,并刷新界面。以下是Python的具体代码:
import os
import PIL,numpy
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
import time
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
distace=((y2-y1)**2+(x2-x1)**2)**0.5
os.system(adb shell input swipe 320 410 320 410 {}.format(int(distace*1.35)))
def on_calck(event,coor=[]):#绑定鼠标单击事件
global need_update
coor.append((event.xdata,event.ydata))
if len(coor) == 2:
jump_to_next(coor.pop(),coor.pop())
need_update = True
def update_screen(frame):#更新图片
global need_update
if need_update:
time.sleep(0.7)
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_calck)
ani =FuncAnimation(figure,update_screen,interval=50,blit=True)#刷新
plt.show()
