微信跳一跳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解釋文件即可
點一下開始,再點一下結束的位置自動跳了
暫時還沒有自動跳的代碼,等我學了圖片分割再說
碼
總結
以上是生活随笔為你收集整理的微信跳一跳python全部代码_微信跳一跳python代码的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python打开360浏览器_pytho
- 下一篇: python如何离线安装第三方模块_扣丁