My WinForms app moves the mouse cursor about the form simply by setting the Cursor.Position
property in some kind of a loop with a timer.
I would like this movement to continue only till the user does not wield the mouse himself to move it. As soon as he or she does, I want my code to stop.
Therefore, I need a way to distinguish between mouse moves that the user generated mouse movement sent vs. those that my application generates.
If you use the Win32 SendInput API to position the mouse cursor, you can set a custom
dwExtraInfo
value in the MOUSEINPUT structure.When processing an asynchronous (posted) message, you can use the Win32 API GetMessageExtraInfo to retrieve the custom value.