feat: enhance swipe and back navigation logic
- Adjusted configuration for reset after swipes to 10 seconds and added action to go back. - Updated flow control to skip back action if a recent reset was triggered within 5 seconds. - Implemented a mechanism to enable back navigation when consecutive misses reach a threshold. - Added GUI options to enable or disable back navigation on misses, ensuring consistency with user settings. - Introduced new diagnostic tools for runtime flag checks and screenshot diagnostics. - Created PowerShell scripts for restoring Start Menu shortcuts and performing system health checks. - Added tests for swipe operations and back navigation to validate new logic.
This commit is contained in:
1 parent
0c3a763d63
commit
dcded08796
19 files changed
+936
-22
No files matched your search
@@ -0,0 +1,69 @@
|
||||
from douyin.core.douyin_fudai import fudai_analyse
|
||||
from douyin.utils import douyin_config
|
||||
|
||||
class DummyOp:
|
||||
def __init__(self):
|
||||
self.clicked_back = False
|
||||
self.clicked_coord = None
|
||||
def click_back(self, device_id=None):
|
||||
print("DummyOp.click_back called, device_id=", device_id)
|
||||
self.clicked_back = True
|
||||
def click(self, device_id, x, y):
|
||||
print(f"DummyOp.click called at ({x},{y}), device_id={device_id}")
|
||||
self.clicked_coord = (x,y)
|
||||
|
||||
|
||||
def simulate():
|
||||
a = fudai_analyse()
|
||||
# use dummy op to avoid real adb
|
||||
a.operation = DummyOp()
|
||||
# ensure config loads (reads config/config.json)
|
||||
a.load_config()
|
||||
print("config enable_back_on_misses ->", getattr(a, "enable_back_on_misses", None))
|
||||
|
||||
# 快速验证:强制设置阈值为 1(触发返回键)
|
||||
a.fudai_exit_after_misses = 1
|
||||
print("(test override) fudai_exit_after_misses ->", a.fudai_exit_after_misses)
|
||||
|
||||
# simulate "not found" path logic
|
||||
cur = int(getattr(a, "_consecutive_no_fudai_count", 0) or 0)
|
||||
print("initial consecutive count ->", cur)
|
||||
cur += 1
|
||||
setattr(a, "_consecutive_no_fudai_count", cur)
|
||||
print("after increment ->", cur)
|
||||
|
||||
threshold = int(getattr(a, "fudai_exit_after_misses", 0) or 0) or None
|
||||
if threshold is None or threshold <= 0:
|
||||
threshold = 30
|
||||
if threshold and cur >= threshold:
|
||||
print("threshold reached: cur=", cur, "threshold=", threshold)
|
||||
enabled = getattr(a, "enable_back_on_misses", None)
|
||||
print("enable_back_on_misses attribute ->", enabled)
|
||||
if enabled is None:
|
||||
# try load from file
|
||||
try:
|
||||
douyin_config.ConfigManager.load_config_from_file(a)
|
||||
enabled = bool(getattr(a, "enable_back_on_misses", True))
|
||||
except Exception:
|
||||
enabled = True
|
||||
print("final enabled ->", enabled)
|
||||
if enabled:
|
||||
try:
|
||||
a.operation.click_back(a.device_id)
|
||||
except Exception:
|
||||
try:
|
||||
# fallback coord click
|
||||
rx = int(getattr(a, "resolution_ratio_x", 1080) or 1080)
|
||||
ry = int(getattr(a, "resolution_ratio_y", 2400) or 2400)
|
||||
back_x = int(50 * rx / 1080)
|
||||
back_y = int(50 * ry / 2400)
|
||||
a.operation.click(a.device_id, back_x, back_y)
|
||||
except Exception:
|
||||
print("both click_back and click fallback failed")
|
||||
else:
|
||||
print("enabled is False; skipping back click")
|
||||
else:
|
||||
print("threshold not reached: cur=", cur, "threshold=", threshold)
|
||||
|
||||
if __name__ == '__main__':
|
||||
simulate()
|
||||
Reference in new issue
Block a user