在 Python 中实现了 WindMouse 算法
2 分•作者: AsfhtgkDavid•6 天前
Hi HN,
WindMouse 是一个相当古老且众所周知的算法,用于生成类似人类的鼠标移动(曲线路径、可变速度、自然减速)。它经常在自动化讨论中被提及,但令人惊讶的是,我找不到一个干净、经过良好测试、可重用的 Python 库实现。
所以我决定自己实现它。
该项目现已作为 <i>WindMouse</i> 发布:
* 强类型(坐标使用 <i>NewType</i>,支持 mypy)
* 两个后端:
```
* PyAutoGUI(跨平台)
* AutoHotkey(Windows)
```
算法本身并不新鲜——实现是。我的目标是创建一个可以下载并立即在项目中使用的东西。
我正在寻求以下方面的帮助:
* <i>在不同的操作系统设置上进行测试</i>(特别是 macOS 边缘情况)
* <i>新的后端</i>(例如,原生 macOS、Wayland、低级 Windows API、游戏引擎、远程桌面)
* 关于 API 设计和参数默认值的反馈
很乐意回答关于算法、设计决策或权衡的问题。
查看原文
Hi HN,<p>WindMouse is a fairly old and well-known algorithm for generating human-like mouse movements (curved paths, variable speed, natural deceleration). It’s often referenced in automation discussions, but surprisingly I couldn’t find a clean, well-tested, reusable implementation as a Python library.<p>So I decided to implement it myself.<p>The project is now released as <i>WindMouse</i>:<p>* Strong typing (<i>NewType</i> for coordinates, mypy-friendly)<p>* Two backends:<p><pre><code> * PyAutoGUI (cross-platform)
* AutoHotkey (Windows)
</code></pre>
The algorithm itself is not new - the implementation is. My goal was to create something that could be downloaded and immediately used in projects.<p>I’m looking for help with:<p>* <i>Testing on different OS setups</i> (especially macOS edge cases)
* <i>New backends</i> (e.g. native macOS, Wayland, low-level Windows APIs, game engines, remote desktops)
* Feedback on API design and parameter defaults<p>Happy to answer questions about the algorithm, design decisions, or tradeoffs.