Record cursor movement

649 views Asked by At

This is more of a conceptual/implementation question, rather than a specific language problem.

Does anybody have any insight into cursor movement recording?
It's very easy to get a cursor's current position, but how would you go about recording the path followed by the cursor?
(To the degree of detail where it could be plotted graphically without ambiguity as to the path taken)

I imagine you could record the cursor's current position repeatedly after a small duration, logging it all to make a list of chronologically visited coordinates, but I'm not sure how frequent (or feasible) the recording should take place; every 10 ms?
I've not even encountered a method of sleeping for such short durations to the nescessary precision!

I'm concerned also about the performance of the sleeping and recording during intense CPU usage; when the user is using the mouse to interact with intensive software.

I'm not even entirely sure where the cursor is really moving. If I sweep my cursor across the screen, has the computer (somewhere internally) acknowledged that I crossed all those pixels, or has my mouse really told it "I was there, now I'm over here, now I'm there".

I do also seek a method of differentiating between fast and slow movement, but for now, I can just observe the plot spacing on a graph of the visited coordinates.

Does anybody have any insight into this? Any potential pitfalls; are my concerns legitimate? Am I going the wrong way about this?

(As is observable, I really need some guidance in the matter)

Thanks!

1

There are 1 answers

2
Greg Hewgill On

It's far easier to log the mouse movements within the same application - just log something on every WM_MOUSEMOVE message. You will get a message periodically updating the mouse pointer location. You will not get a WM_MOUSEMOVE message for every pixel the mouse crosses, but it will jump depending on how fast you move the mouse and how busy the system is.

Logging mouse movements in some other application is going to be slightly more involved. If you have written both the logger and the application being logged, then you can handle WM_MOUSEMOVE in the application being logged, and send a corresponding message to your logger application. Your choice of IPC; a simple SendMessage() might be sufficient.

Logging mouse movements across the whole system is a totally different problem. You may have to hook in at somewhere closer to the driver level.

I just thought of another approach - the CBT (Computer-Based Training) hooks are designed to provide exactly this sort of information across applications. I've never used these though, so you'll have to do more investigation.