NEKO

python微信跳一跳

2018/01/21

通过鼠标点击操作手机版微信跳一跳

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -*- coding:utf-8 -*-
__auther__='neko'
import sys
reload(sys)
sys.setdefaultencoding('gbk')
import os
from math import sqrt
import numpy
import matplotlib.pyplot as plt
from PIL import Image
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(Image.open('screen.png'))

def jump_to_next(point1,point2):
x1,y1=point1
x2,y2=point2
distance=sqrt((x2-x1)**2+(y2-y1)**2)
os.system('adb shell input swipe 320 410 320 410 {}'.format(int(distance*1.35)))#一个像素点按压1.35毫秒可以通过爬虫抓包获得


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==True:

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_click)
ani=FuncAnimation(figure,update_screen,interval=50,blit=True)
plt.show()

原文作者: n3k0

发表日期: January 21st 2018, 10:51:28

发出嘶吼: 没有魔夜2玩我要死了

CATALOG