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? :)
Mouse movements can be used to infer a user's intent and focus while browsing a website. By using mouse movements in usability testing, researchers can determine if users are confused, if their expectations are met, where their attention is focused, and much additional information.
This code uses moveTo() function, which takes x and y coordinates, and an optional duration argument. This function moves your mouse pointer from it's current location to x, y coordinate, and takes time as specified by duration argument to do so.
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
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.
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).
Create a simple test app which shows a random positioned dot every two seconds. Follow the dot yourself and record your natural mouse movements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With