合并代码

This commit is contained in:
2025-09-16 15:31:55 +08:00
parent b91aa99048
commit a0e1f9ef8d
3 changed files with 88 additions and 27 deletions

View File

@@ -1,4 +1,6 @@
import random
import re
import time
import tidevice
import wda
@@ -177,7 +179,25 @@ class ControlUtils(object):
session.tap(left_x, center_y)
# 点击一个随机范围
@classmethod
def tap_mini_cluster(cls, center_x: int, center_y: int, session, points=5, duration_ms=60):
"""
以 (center_x, center_y) 为中心,在 3×3 像素范围内摆 `points` 个邻近坐标,
一次性同时按下,持续 `duration_ms` 后抬起。
"""
# 1. 生成邻像素坐标±1 像素内)
cluster = []
for i in range(points):
dx = random.randint(-1, 1)
dy = random.randint(-1, 1)
cluster.append((center_x + dx, center_y + dy))
# 2. 随机持续时间 50100 ms
duration_s = random.randint(50, 100) / 1000.0
# 3. 下发多点触控
session.tap_hold(cluster, duration=duration_s)
# 检测五分钟前和当前的状态是否相同
# @classmethod