创建python项目jump_weixin,新建python程序jump.py

需要4个辅助文件【adb.exe,AdbWinApi.dll,AdbWinUsbApi.dll,fastboot.exe】,放到项目根目录

辅助文件下载地址:链接:https://pan.baidu.com/s/1sljznFR 密码:gzeg

目录结构如下:

编辑jump.py:

import os
import numpy
import matplotlib.pyplot as plt
import PIL
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(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 300 400 300 400 {}'.format(int((distance * 1.35))))  # 按下的坐标,抬起的坐标,按压的时间
    global need_update
    need_update = True
    # time.sleep(1)

def on_click(event, coor=[]):
    # 参数event是点击的位置
    x, y = event.xdata, event.ydata  # 刚刚点击的坐标
    coor.append((x, y))  # 把一次点击的坐标添加到列表
    if len(coor) == 2:  # 通过坐标的数量,判断当前是否点击了两次
        # jump_to_next(coor[0],coor[1])
        # coor=[]
        # 用列表的pop代替上面的方法
        jump_to_next(coor.pop(), coor.pop())

def update_screen(frames):
    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=300, blit=True)
plt.show()  # 显示

执行时,需要将手机调成开启USB调试模式,打开微信跳一跳界面,用手机数据线连接电脑。

执行方式:打开命令行工具cmd,进入jump_weixin项目目录,执行python jump.py

会弹出如下图形程序,用鼠标点击开始点与结束点,等待图片刷新后,再次点击开始点与结束点。

好了,大致就是这样了,

看看我刷的(第三的是我,我不是朋友圈里唯一刷分的,强中自有强中手):

是不是瞬间失去了游戏的乐趣?

补充:

C:\Users\lcg>pip install numpy
Collecting numpy
  Downloading numpy--cp36-none-win_amd64.whl (.4MB)
    % |████████████████████████████████| .4MB 75kB/s
Installing collected packages: numpy
Successfully installed numpy-

C:\Users\lcg>pip install matplotlib
Collecting matplotlib
  Downloading matplotlib--cp36-cp36m-win_amd64.whl (.7MB)
    % |████████████████████████████████| .7MB 55kB/s
Collecting six>=1.10 (from matplotlib)
  Downloading six--py2.py3-none-any.whl
Requirement already satisfied: numpy>= in c:\python36\lib\site-packages (from matplotlib)
Collecting pyparsing!=,!=,!=,>= (from matplotlib)
  Downloading pyparsing--py2.py3-none-any.whl (56kB)
    % |████████████████████████████████| 61kB 58kB/s
Collecting python-dateutil>=2.0 (from matplotlib)
  Downloading python_dateutil--py2.py3-none-any.whl (194kB)
    % |████████████████████████████████| 194kB 141kB/s
Requirement already satisfied: pytz in c:\python36\lib\site-packages (from matplotlib)
Collecting cycler>=0.10 (from matplotlib)
  Downloading cycler--py2.py3-none-any.whl
Installing collected packages: six, pyparsing, python-dateutil, cycler, matplotlib
Successfully installed cycler- matplotlib- pyparsing- python-dateutil- six-

C:\Users\lcg>pip install pillow
Collecting pillow
  Downloading Pillow--cp36-cp36m-win_amd64.whl (.6MB)
    % |████████████████████████████████| .6MB 199kB/s
Installing collected packages: pillow
Successfully installed pillow-

外部库的安装

最新文章

  1. dagger2系列之生成类实例
  2. SQLSERVER单表CRUD通用方法
  3. tee 命令基本使用方法、输出到多个文件
  4. JAVA 遍历文件夹下的所有文件
  5. VirtualBox虚拟机无法选择桥接方式
  6. QQ聊天原理初识
  7. Oracle JDBC版本区别(转)
  8. js两个判断&&的值与||的值
  9. 如何让Enum枚举实现异或操作
  10. 纯小白入手 vue3.0 CLI - 3.3 - 路由的导航守卫
  11. metamask源码学习-ui/index.js
  12. css文件 如何使背景图片大小适应div的大小
  13. meson 中调用shell script
  14. openresty 编译ngx_pagespeed 模块-docker 构建
  15. 如何获取帮助———— QQ群讨论摘要
  16. Python 基本语法,文件读写,数据结构和类型
  17. [Linux实用工具]Linux监控工具munin的展示(Nginx)
  18. Java发送HTTP POST请求示例
  19. 如何注册iClap账号?
  20. Matlab 日期频次统计

热门文章

  1. LA3905
  2. flask(十)使用alembic,进行数据库结构管理,升级,加表,加项
  3. Alpha阶段项目复审
  4. 玩转X-CTR100 l STM32F4 l ADC 模拟数字转换
  5. Vue2.0 分页插件pagination使用详细说明
  6. HDU 2907
  7. markdown添加本地图片
  8. 【error】segmentation fault分析
  9. [Algorithm] A nonrecursive algorithm for enumerating all permutations of the numbers {1,2,...,n}
  10. Loj 2008 小凸想跑步