首頁(yè) 資訊 微信跳一跳腳本重出江湖,python實(shí)現(xiàn)安卓&iOS自動(dòng)版與手動(dòng)版!

微信跳一跳腳本重出江湖,python實(shí)現(xiàn)安卓&iOS自動(dòng)版與手動(dòng)版!

來(lái)源:泰然健康網(wǎng) 時(shí)間:2026年04月08日 19:07

前面一段時(shí)間在GitHub上看到有人利用Python玩一款名為“跳一跳”的微信小程序,于是打算自己也來(lái)試一試,畢竟這款小游戲最近吸引了眾多人的目光。

演示工具

電腦系統(tǒng):Win10

Python版本:2.7.13(64位)

環(huán)境配置

Step1:安裝Python

安裝Python2.7并添加到環(huán)境變量中。

Step2:配置adb

將相關(guān)文件中提供的adb.zip文件解壓,將解壓后的文件夾添加到環(huán)境變量中。

(Win10系統(tǒng):右鍵“此電腦”→“屬性”→“高級(jí)系統(tǒng)設(shè)置”→“環(huán)境變量”→雙擊“Path”,將adb文件夾的路徑添加進(jìn)去即可。)

例如下圖:

添加成功后在cmd窗口輸入adb會(huì)有類似如下圖所示的顯示:

Step3:安裝依賴庫(kù)

解壓相關(guān)文件中提供的wechat_jump_game.rar文件。cmd窗口切換到解壓后的文件夾內(nèi)后輸入pip install -r requirements.txt耐心等待相關(guān)依賴庫(kù)安裝完成即可。

如下圖所示:

小編給大家推薦一個(gè)學(xué)習(xí)氛圍超好的地方,python交流企鵝裙:【6.1.1,五三零,1.0.1】!適合在校大學(xué)生,小白,想轉(zhuǎn)行,想通過(guò)這個(gè)找工作的加入。裙里有大量學(xué)習(xí)資料,有大神解答交流問(wèn)題,每晚都有免費(fèi)的直播課程

使用演示

一、安卓手機(jī)(已成功)

cmd窗口中路徑保持在wechat_jump_game不變。

Step1:

將安卓手機(jī)與電腦連接并開啟安卓手機(jī)的USB調(diào)試(安全模式)。(請(qǐng)根據(jù)機(jī)型和系統(tǒng)自行百度開啟方式。)

Step2:

手機(jī)端打開微信小程序“跳一跳”并點(diǎn)擊“開始游戲”。

Step3:

電腦端在cmd窗口中輸入:

python wechat_jump_auto.py即可。

如下圖所示:

此時(shí)你可以發(fā)現(xiàn)小人已經(jīng)自己開始跳起來(lái)了!

可能剛開始上手的時(shí)候,因?yàn)闀r(shí)間距離之間的關(guān)系把握不恰當(dāng),只能跳出幾個(gè)就掉到了臺(tái)子下面。如果能利用圖像識(shí)別精確測(cè)量出起始和目標(biāo)點(diǎn)之間測(cè)距離,就可以估計(jì)按壓的時(shí)間來(lái)精確跳躍。

代碼分iOS與安卓

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

from __future__ import print_function, division

import os

import time

import datetime

import matplotlib.pyplot as plt

import matplotlib.animation as animation

import cv2

VERSION = "1.1.4"

scale = 0.25

template = cv2.imread('./resource/image/character.png')

template = cv2.resize(template, (0, 0), fx=scale, fy=scale)

template_size = template.shape[:2]

def search(img):

result = cv2.matchTemplate(img, template, cv2.TM_SQDIFF)

min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)

cv2.rectangle(

img,

(min_loc[0], min_loc[1]),

(min_loc[0] + template_size[1], min_loc[1] + template_size[0]),

(255, 0, 0),

4)

return img, min_loc[0] + template_size[1] / 2, min_loc[1] + template_size[0]

def pull_screenshot():

filename = datetime.datetime.now().strftime("%H%M%S") + '.png'

os.system('mv autojump.png {}'.format(filename))

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

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

def jump(distance):

press_time = distance * 1.35

press_time = int(press_time)

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

print(cmd)

os.system(cmd)

def update_data():

global src_x, src_y

img = cv2.imread('./autojump.png')

img = cv2.resize(img, (0, 0), fx=scale, fy=scale)

img, src_x, src_y = search(img)

return img

fig = plt.figure()

pull_screenshot()

img = update_data()

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

update = True

def updatefig(*args):

global update

if update:

time.sleep(1)

pull_screenshot()

im.set_array(update_data())

update = False

return im,

def on_click(event):

global update

global src_x, src_y

dst_x, dst_y = event.xdata, event.ydata

distance = (dst_x - src_x)**2 + (dst_y - src_y)**2

distance = (distance ** 0.5) / scale

print('distance = ', distance)

jump(distance)

update = True

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

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

plt.show()

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

import time

import wda

import numpy as np

import matplotlib.pyplot as plt

import matplotlib.animation as animation

from PIL import Image

# 截圖距離 * time_coefficient = 按鍵時(shí)長(zhǎng)

# time_coefficient:

# iphonex: 0.00125

# iphone6: 0.00196

# iphone6s plus: 0.00120

time_coefficient = 0.00120

VERSION = "1.1.4"

c = wda.Client()

s = c.session()

def pull_screenshot():

c.screenshot('autojump.png')

def jump(distance):

press_time = distance * time_coefficient

press_time = press_time

print('press_time = ',press_time)

s.tap_hold(200, 200, press_time)

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)

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()

原理說(shuō)明

由于微信檢測(cè)非常嚴(yán)厲,這里的防禁代碼可能已經(jīng)不起作用,主要供學(xué)習(xí)用途

將手機(jī)點(diǎn)擊到《跳一跳》小程序界面

用 ADB 工具獲取當(dāng)前手機(jī)截圖,并用 ADB 將截圖 pull 上來(lái)

adb shell screencap -p /sdcard/autojump.png

adb pull /sdcard/autojump.png .

計(jì)算按壓時(shí)間

手動(dòng)版:用 Matplotlib 顯示截圖,用鼠標(biāo)先點(diǎn)擊起始點(diǎn)位置,然后點(diǎn)擊目標(biāo)位置,計(jì)算像素距離;

自動(dòng)版:靠棋子的顏色來(lái)識(shí)別棋子,靠底色和方塊的色差來(lái)識(shí)別棋盤;

用 ADB 工具點(diǎn)擊屏幕蓄力一跳

adb shell input swipe x y x y time(ms)

使用教程

相關(guān)軟件工具安裝和使用步驟請(qǐng)參考 Android 和 iOS 操作步驟

PS:

如果屏幕分辨率不能成功探測(cè),請(qǐng)按照你的手機(jī)分辨率從相應(yīng)的config文件夾將config.json文件拷貝到 *.py 同級(jí)目錄(wechat_jump_game下)。

二、蘋果手機(jī)(未嘗試)

蘋果手機(jī)需要配置WebDriverAgentRunner,本人不使用Mac,因此無(wú)法測(cè)試代碼的有效性。在相關(guān)文件中,本人也提供了一份CSDN中積分下載的WebDriverAgent.rar文件,有需要者可參考相關(guān)網(wǎng)絡(luò)資料進(jìn)行配置。

運(yùn)行WebDriverAgentRunner并打開微信“跳一跳”程序界面。

Step2:

運(yùn)行腳本。有兩種模式可供選擇:

(1)手動(dòng)輔助跳:

①命令行輸入:

python3 wechat_jump_iOS_py3.py后回車運(yùn)行;

②依次點(diǎn)擊彈出窗口中的起始位置和目標(biāo)位置,程序會(huì)自動(dòng)計(jì)算距離后起跳;

③根據(jù)起跳的精準(zhǔn)性更改源代碼中的time_coefficient參數(shù),直到獲得最佳取值。

(2)自動(dòng)連續(xù)跳:

①命令行輸入:

python3 wechat_jump_auto_iOS.py后回車運(yùn)行;

②根據(jù)起跳的精準(zhǔn)性更改機(jī)型對(duì)應(yīng)的config.json 文件中的press_coefficient參數(shù),直到獲得最佳取值。

PS:

如果屏幕分辨率不能成功探測(cè),處理方式與安卓手機(jī)中的處理方式類似。

相關(guān)知識(shí)

微信跳一跳腳本重出江湖,python實(shí)現(xiàn)安卓&iOS自動(dòng)版與手動(dòng)版!
跳一跳自動(dòng)跳腳本輔助
ios微信步數(shù)和健康不一樣 微信步數(shù)和iphone健康不一致
Python獲取微信運(yùn)動(dòng)列表 python改微信步數(shù)
錦繡江湖腳本免費(fèi)輔助教程 錦繡江湖新國(guó)風(fēng)武俠放置RPG手游
躍動(dòng)跳繩app下載 躍動(dòng)跳繩 for Android v1.2.4 安卓手機(jī)版 下載
小米運(yùn)動(dòng)健康app安卓版下載
天天跳繩安卓版下載
科技早茶:華為Mate 10大曝光,安卓微信6.5.10版發(fā)布
自動(dòng)精靈免費(fèi)腳本下載安裝手機(jī)版 v2.27.2 安卓版

網(wǎng)址: 微信跳一跳腳本重出江湖,python實(shí)現(xiàn)安卓&iOS自動(dòng)版與手動(dòng)版! http://m.gysdgmq.cn/newsview1930237.html

推薦資訊