python跳一跳辅助学习,,微信跳一跳辅助工具准


微信跳一跳辅助工具

准备工具

adb驱动安卓手机打开手机的调试模式usb接好手机和电脑

PyCharm:全宇宙唯一一款专门用于Python开发IDE工具

实现原理:

获取手机的实时的截图点击起始位置和落地位置技算两个点的距离计算按压时间发送按压指令重新刷新手机截图
实现代码:
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‘)#获取当前界面的手机截图    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 340 490 340 490 {}‘.format(int(distance*1)))    #手机的单击位置,0 0 0 0 0 ,x轴y轴滑动后的xy轴单击时间def on_calck(event, coor=[]):#绑定鼠标的单击事件[(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):#更新图片/从画图片    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() #创建一个空白的图片对象、创建一张图片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()

详情:
https://github.com/wangshub/wechat_jump_game

python跳一跳辅助学习

评论关闭