像人类一样模拟鼠标运动的算法?

发布于 2024-08-17 11:25:15 字数 210 浏览 2 评论 0原文

我需要测试一个将某些鼠标移动视为“手势”的软件。对于这样的任务,我需要模拟鼠标从 A 点到 B 点的移动,不是直线移动,而是像真正的鼠标移动一样 - 有曲线,有点锯齿状等。是否有任何可用的解决方案(算法/代码本身,而不是我可以使用的库/exe)?

当然,我可以自己写一些简单的正弦数学,但这将是对人手引导鼠标的非常粗略的模拟。也许这样的任务已经解决了很多次了,我可以借用现有的代码吗? :)

I need to test a software that treats some mouse movements as "gestures". For such a task I need to emulate mouse movement from point A to point B, not in straight line, but as a real mouse moves - with curves, a bit of jaggedyness etc. Is there any available solution (algorithm/code itself, not a library/exe) that I can use?

Of course I can write some simple sinusoidal math by myself, but this would be a very crude emulation of a human hand leading a mouse. Perhaps such a task has been solved already numerous times, and I can just borrow an existing code? :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

夜雨飘雪 2024-08-24 11:25:15

查看 Mouse.simba 文件它是 SRL 框架 的一部分,该框架是一个宏程序,旨在与 Runescape。 Runescape 具有广泛的宏检测功能,因此 SRL 框架的所有部分都已开发得尽可能人性化 - 特别是鼠标功能。

代码是 Pascal 语言,但应该很容易阅读。看看 BenLand100 的 MMouse() 程序,它的移动非常逼真,可以执行循环和超越目标以及连续变化的加速度和方向(现在还具有笔记本电脑触摸板类型的移动)等高级动作。如果您想测试它,您需要下载 SIMBA启用 SRL-include

Take a look at the Mouse.simba file which is part of the SRL Framework, a macro program designed to work with online games like Runescape. Runescape has extensive macro detection capabilities so all parts of the SRL Framework have been developed to look as human as possible - the mouse functions in particular.

The code is in Pascal but should be quite easy to read. Look at the MMouse() procedure by BenLand100 it moves very realistically doing advanced movements like loops and overshooting its target as well as continuously varying accelerations and directions (also now has laptop touchpad type movements). If you want to test it you'll need to download SIMBA and enable the SRL-include.

似梦非梦 2024-08-24 11:25:15

对于未来的任何人:我开发了一个 Java 库,它完全符合 OP 的要求。运动中的噪声/锯齿、正弦弧、稍微超出位置等。此外,该库在编写时考虑了扩展和配置的可能性,因此如果默认解决方案与情况不匹配,任何人都可以对其进行微调。现已可从 Maven Central 获取。

https://github.com/JoonasVali/NaturalMouseMotion

For anyone in the future: I developed a library for Java, that does exactly what OP is asking. The noise/jaggedness in movement, sinusoidal arcs, overshooting the position a bit, etc. Plus the library is written with extension and configuration possibilities in mind, so anyone can fine tune it, if the default solution is not matching the case. Available from Maven Central now.

https://github.com/JoonasVali/NaturalMouseMotion

情绪 2024-08-24 11:25:15

记录一些真实的手势并制作一种回放它们的方法怎么样?这将与您可以合成的任何东西一样真实,并且是可重复的(这对于测试来说很好)。

How about recording some real gestures and making a way to play them back? That's going to be as real as anything you can synthesize, and it would be repeatable (which is nice for testing).

梦魇绽荼蘼 2024-08-24 11:25:15

创建一个简单的测试应用程序,每两秒显示一个随机定位的点。自己跟随该点并记录您的自然鼠标移动。

Create a simple test app which shows a random positioned dot every two seconds. Follow the dot yourself and record your natural mouse movements.

戏剧牡丹亭 2024-08-24 11:25:15

捕捉这种行为的一种方法是在屏幕上定义一个不可见的“网格”,您可以在其中跟踪鼠标在其行程中移动过的方格。

如果这部分工作并正确记录,则无需对其进行测试,因为您知道每个网格方块都在完成其工作。这样,解释手势也变得更加容易。

One way to capture this behaviour could be to define an invisible "grid" on the screen, where you track which squares the mouse moves through on its journey.

If this part works and records properly, there's no need to bombard it with tests, since you know that each grid square does its job. Interpreting the gesture is also made easier with this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文