1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 微信跳一跳python全部代码_微信跳一跳python代码

微信跳一跳python全部代码_微信跳一跳python代码

时间:2018-08-05 03:09:16

相关推荐

微信跳一跳python全部代码_微信跳一跳python代码

今天早上有些人嘲笑我手残

mdzz# -*- coding: utf-8 -*-

import os

import time

import numpy as np

import matplotlib.pyplot as plt

import matplotlib.animation as animation

from PIL import Image

def pull_screenshot():

os.system('adb shell screencap -p /sdcard/autojump.png')

os.system('adb pull /sdcard/autojump.png .')

def jump(distance):

press_time = distance * 1

press_time = int(press_time)

cmd = 'adb shell input swipe 320 410 320 410 ' + str(press_time)

print(cmd)

os.system(cmd)

fig = plt.figure()

pull_screenshot()

img = np.array(Image.open('autojump.png'))

im = plt.imshow(img, animated=True)

update = True

click_count = 0

cor = []

def update_data():

return np.array(Image.open('autojump.png'))

def updatefig(*args):

global update

if update:

time.sleep(1.5)

pull_screenshot()

im.set_array(update_data())

update = False

return im,

def on_click(event):

global update

global ix, iy

global click_count

global cor

ix, iy = event.xdata, event.ydata

coords = [(ix, iy)]

print('now = ', coords)

cor.append(coords)

click_count += 1

if click_count > 1:

click_count = 0

cor1 = cor.pop()

cor2 = cor.pop()

distance = (cor1[0][0] - cor2[0][0])**2 + (cor1[0][1] - cor2[0][1])**2

distance = distance ** 0.5

print('distance = ', distance)

jump(distance)

update = True

fig.canvas.mpl_connect('button_press_event', on_click)

ani = animation.FuncAnimation(fig, updatefig, interval=50, blit=True)

plt.show()

支持python3.6

安装PIL组件

计算机下载adb软件,解压

我的仓库已经有了,所以不用下载了

将python代码文件复制到adb解压文件夹里

打开cmd

cd到adb文件夹位置

连接手机,打开usb调试,部分手机需要点击允许adb调试

cmd中输入命令 adb devices

成功连接后

python解释文件即可

点一下开始,再点一下结束的位置自动跳了

暂时还没有自动跳的代码,等我学了图片分割再说

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。