发布于2020-07-03 16:12 阅读(1119) 评论(0) 点赞(0) 收藏(0)
0
1
2
3
4
5
6
7
# name: have a jump # author: DYBOY # time: 2017-01-06 # charset: utf-8 import os import PIL import 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/1.png')#获取当前界面的手机截图并保存到根目录 os.system('adb pull /sdcard/1.png') #获取手机中的截图 return numpy.array(PIL.Image.open('1.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*2.1))) #绑定的鼠标单击事件 def on_click(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(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_click) ani = FuncAnimation(figure, update_screen, interval=50, blit=True) plt.show()
0
1
2
3
4
5
6
7
作者:bzxx111
链接: https://www.pythonheidong.com/blog/article/433615/aadd83b3a49ee94e009d/
来源: python黑洞网
任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任
昵称:
评论内容:(最多支持255个字符)
Copyright © 2018-2021 python黑洞网 All Rights Reserved 版权所有,并保留所有权利。 京ICP备18063182号-1
投诉与举报,广告合作请联系z452as@163.com或QQ3083709327
免责声明:网站文章均由用户上传,仅供读者学习交流使用,禁止用做商业用途。若文章涉及色情,反动,侵权等违法信息,请向我们举报,一经核实我们会立即删除!