Skip to content

fix: make macro stop interruptible and release held inputs - #8

Draft
2002yy wants to merge 1 commit into
mainfrom
codex/interruptible-macro-stop-20261119
Draft

2002yy wants to merge 1 commit into
mainfrom
codex/interruptible-macro-stop-20261119

Conversation

@2002yy

@2002yy 2002yy commented Nov 19, 2026

Copy link
Copy Markdown
Owner

第七批:转向 AutoClicker-Pro,修复真实用户的停止/紧急中断风险

这是 独立于 Cardfront 的 Draft PR,基于本仓库 main,不自动合并。

实际工程证据

审查 core/engine.py 的两条生产执行链后发现:

  1. 宏按录制时间戳回放时直接 time.sleep(delay)。当相邻动作相隔 10 秒甚至更久,用户即使按停止,回放工作线程也要等睡眠结束才能退出。
  2. 配对的鼠标/键盘 press 和 release 依赖后续时间轴。停止发生在二者之间时,程序可能留下系统仍认为按住的鼠标键或键盘键。
  3. 普通连点模式的间隔上限是 60,000ms,循环睡眠同样不可中断。
  4. 停止后工作线程尚未退出时立刻再次启动,旧线程可能随后清理新会话的运行标志。

这些影响真实使用安全性,优先级高于无依据地删掉单元测试。

修复边界

  • 将长时间戳、普通连点间隔、重复间隔以及未配对按住时长改成最多约 50ms 一轮的可中断等待。
  • 宏按下后追踪待完成的 release;用户中断或自动停止时,在 finally 补发释放(含鼠标组合键修饰键)。
  • 新执行前检查上一工作线程是否已真正退出;退出应用时短暂等待释放完成。
  • 不更改宏存储格式、历史文件兼容、UI 配置或用户已有宏的正常回放时序。

验证

在已有 tests/test_engine.py 增加 5 个针对性测试,覆盖:

  • 人工停止在 10 秒鼠标拖拽间隔;
  • 人工停止在 10 秒键盘按住间隔;
  • 自动停止在录制的长间隔;
  • 普通连点 60 秒间隔期间停止;
  • 未配对鼠标按住 5 秒期间停止。

本地:

  • 引擎测试 78 项:77 通过、1 个需要图形桌面的 GUI 用例跳过(使用 Linux 的 pynput 输入接口替身)。
  • 另外 55 项数据模型、加密、验证和持久化单测通过。
  • python -m compileall -q core tests 与 git diff --check 通过。

注意:Linux 本地没有 pynput/Windows 桌面,不能把以上结果当作真实 Windows GUI/打包验收。仓库正式 build-windows CI 将在 Windows runner 上执行完整 unittest + PyInstaller 打包;未完成前保持 Draft。

Make recorded timestamp gaps, simple-click intervals and configured holds stop-responsive. Release paired mouse/key presses when replay is cancelled mid-sequence; block a new playback while the previous worker is still exiting. Cover manual stop and auto-stop at real timing boundaries.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant