python跳一跳辅助学习,,微信跳一跳辅助工具准
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跳一跳辅助学习
相关内容
- Python自动化开发04,,装饰器装饰器: 本质
- Python 之 Sqlite3数据库,, SQLite数据
- Python基础(十六)-操作数据库pymysql模块,,一、pymysq
- Linux安装python3、pip以及pycharm,,Python3安装L
- python如何使用pymysql模块,,Python 3.x
- python中非常好用的数据库管理工具,,dataset对于操
- Python学习之路!!!之模块,,模块: 模块即是文
- python中关于操作时间的方法(一),,在python编程操
- python基础_相似对比,,1. __file_
- python_socket应用,,一客户端/服务端架构
评论关闭