views:

517

answers:

5

Hello

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? :)

+4  A: 

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).

Adrian McCarthy
It's a good way, but it will ensure only that program in question operates on some predefined movements. And i want to feed it a million of different movements to test :).
Eye of Hell
Then perhaps you should start with a few recorded paths, and apply fuzz testing to generate millions of variants.
Adrian McCarthy
+1  A: 

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

Viktor Sehr
+3  A: 

Take a look at the Mouse.scar file which is part of the SRL Framework (SVN repos, introduction), 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 SCAR and enable Subversion in it.

Callum Rogers
Is Pascal case sensitive or not? :)
Eye of Hell
No, it is not case sensitive. The standard is to capitalise all the words in procedures/function names (like ThisIsAProcedure and AndSoIsThis) and to use thisType ofCapitalisation for variables. Many of the functions it uses relates to the rest of the framework or are ones built into SCAR like GetMousePos.
Callum Rogers
Thanks, i have successfully translated a code to C++. Works like a charm :)
Eye of Hell
Good to hear it xD
Callum Rogers
A: 

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.

Tor Valamo
A: 

Can you please post the code somewhere ? I tried translating that pascal code but it doesn't work and it crashes.The WindMouse function is a beast, I have no idea what's going wrong. I would be really grateful, I've hit a wall with my sorry attempt of a code.

Kesarion
Please send me request to grigory.v.p{аt}gmail.com, i will send you source code as an attachment.
Eye of Hell