Python中如何实现微信自动跳一跳功能?
JJGamer - Jump-Jump auto Gamer
随便写了一个,自动跳一般能一两千分吧,把 Device 里面的参数改一改,关键是把 coef 变量调准确了,大致就能跳个好分数。有空的话再升级一下程序。
Python中如何实现微信自动跳一跳功能?
6 回复
之前想要分析一下,但是 python 数据分析这一块不熟练,拿你的看看代码
要实现微信跳一跳的自动玩,核心是模拟触屏操作。这里提供一个基于ADB和图像识别的完整方案。
import subprocess
import time
import random
from PIL import Image
import numpy as np
import math
def pull_screenshot():
"""获取手机屏幕截图"""
subprocess.call('adb shell screencap -p /sdcard/screenshot.png', shell=True)
subprocess.call('adb pull /sdcard/screenshot.png .', shell=True)
return Image.open('./screenshot.png')
def find_player_and_target(img):
"""识别棋子和目标中心点"""
w, h = img.size
img_array = np.array(img)
# 找棋子(底部固定位置的小人)
player_x, player_y = 0, 0
for y in range(h-1, int(h/3), -1):
for x in range(w):
pixel = img_array[y][x]
# 棋子颜色特征(红色小人)
if 50 < pixel[0] < 60 and 50 < pixel[1] < 60 and 90 < pixel[2] < 100:
player_x, player_y = x, y
break
if player_x > 0:
break
# 找目标中心点(顶部白色或浅色区域)
target_x, target_y = 0, 0
for y in range(int(h/3)):
for x in range(w):
pixel = img_array[y][x]
# 目标平台颜色特征
if pixel[0] > 200 and pixel[1] > 200 and pixel[2] > 200:
target_x, target_y = x, y
break
if target_x > 0:
break
return (player_x, player_y), (target_x, target_y)
def calculate_distance(player, target):
"""计算按压时间"""
distance = math.sqrt((target[0] - player[0])**2 + (target[1] - player[1])**2)
press_time = distance * 1.35 # 系数需要根据手机调整
return int(press_time)
def jump(press_time):
"""模拟按压操作"""
cmd = f'adb shell input swipe 500 500 500 500 {press_time}'
subprocess.call(cmd, shell=True)
def main():
print("开始自动跳一跳...")
time.sleep(2)
while True:
# 1. 截图
img = pull_screenshot()
# 2. 识别位置
player_pos, target_pos = find_player_and_target(img)
if player_pos[0] == 0 or target_pos[0] == 0:
print("识别失败,等待重试...")
time.sleep(1)
continue
# 3. 计算距离和按压时间
press_time = calculate_distance(player_pos, target_pos)
# 4. 执行跳跃
print(f"棋子位置:{player_pos}, 目标位置:{target_pos}, 按压时间:{press_time}ms")
jump(press_time)
# 5. 等待落地
time.sleep(2 + random.random())
if __name__ == '__main__':
main()
需要准备:
- 安装ADB工具并连接手机
- 安装Python依赖:
pip install Pillow numpy - 手机开启USB调试模式
关键点说明:
- 通过ADB命令获取屏幕截图和控制触摸
- 颜色识别定位棋子和目标位置
- 距离与按压时间成正比关系
- 每次跳跃后需要等待画面稳定
注意: 不同手机分辨率需要调整识别参数和按压系数。
总结:用ADB截图+图像识别就能实现基础自动化。
我昨天用 github 比较火的那个 python 脚本跑了五百多分都被微信给和谐了
iOS 的不行吗?
我手边没有 iOS 设备,不过最近有机会的话尝试一下
应该只是没到周一,没刷新排行榜吧

