python3.7实现微信跳一跳作弊器(参考网络视频教程)

 由于实现方式需要用到adb来控制自己的手机进行操作,所以此处方式放上需要的adb.exe文件地址。

链接: https://pan.baidu.com/s/1OOK0uy1GZNza0pVpRpQK0w

密码: 9ebg

# encoding=utf-8
# Created by double lin at 2018/8/19
# 准备工具
# adb驱动
# 安卓手机
# 打开手机调试模式
# usb线与手机保持连通状态

# 获取手机实时截图(页面)
# 获取手机页面中跳一跳的位置(点击起始和终点位置)
# 计算长度
# 计算按压时间
# 发送按压指令
# 刷新手机页面

import os
import PIL,numpy
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
import time
need_update = True

def get_image_screen():
    # 通过命令行操作adb对手机屏幕进行截屏操作
    os.system('adb shell screencap -p /sdcard/screen.png')

    # 对手机页面进行截图
    # 将截图获取到本程序对应的文件夹中
    # 从截图保存的文件夹中将我们截图的内容抓取出来,拿到当前文件夹中
    os.system('adb pull /sdcard/screen.png')

    # 打开图片
    # 使用numpy中的array方法根据像素点进行图片创建
    return numpy.array(PIL.Image.open('screen.png'))
    # return PIL.Image.open('screen.png')

# 从一个点跳到下一个点去
def jump_to_next(point1, point2):
    x1,y1 = point1
    x2,y2 = point2
    print (x1,y1)
    print (x2,y2)
    distance = ((x1-x2) ** 2 + (y1-y2) ** 2) ** 0.5
    os.system('adb shell input swipe 320 410 320 410 {}'.format(int(distance*1.35)))

def on_click(event, coor=[]):
    coor.append((event.xdata,event.ydata))
    global need_update
    # 计算距离
    if len(coor) == 2:
        # 执行带有括号的函数,返回执行的结果到调用对象中
        # 否则是直接在调用内容中调用该对象,执行对应函数,不反悔执行结果到调用它的对象中
        jump_to_next(coor.pop(),coor.pop())
        need_update = True

# 更新图片重构图片
def update_image(frame):
    global need_update
    if need_update:
        time.sleep(1)
        axes_image.set_array(get_image_screen())
        # axes_image = get_image_screen()
        need_update = False
    return axes_image,

# 创建一个空白面板可以将我们的图片放上去
figure = plt.figure()

# 像素点图片
# 将获取的图片画在一个坐标图上面去
axes_image = plt.imshow(get_image_screen(),animated=True)

# 对手机的按压操作进行动作的绑定
figure.canvas.mpl_connect('button_press_event', on_click)

# 实例化一个类对象,进行图片的刷新操作
ani = FuncAnimation(figure,update_image,interval=20,blit=True)

plt.show()

猜你喜欢

转载自blog.csdn.net/qq_32670879/article/details/81902475