Reputation: 5618
Is there a way to detect this?
Imagine you would have an application where you are doing something and there is a Backgroundthread which is listening and waiting until the mouse will be moved - (no matter how far):
Left
Right
Left
Right
Left
Right
Left
Right
Left
Right
Which fires a trigger or calls a specific method.
Any ideas?
Upvotes: 0
Views: 1337
Reputation: 3177
Get the current position of mouse pointer. Move to new location. If the new location's X-Cordinate is lesser than the previuos position's X-Cordinate then it means mouse has moved left. Similary for moving right. Every time the new position will become base position. You can keep a counter and if count is 5 do what ever you wish.
Upvotes: 2
Reputation: 62246
Don't see, from the question provided perspective to use another thread for this.
Just listen for MouseMove
event over whatevere is it, and detect mouse move direction.
You can do that by substracting corrdinates recived by the event handler itself.
The thing here comes to decision of tollerance you are going to have in detection algo.
To be more clear:
If the difference of X
value is bigger then (say) 1
, count that as move to right, if it less then -1
, count that like move to left.
Something like this.
Upvotes: 2
Reputation: 45135
Use the MouseMove event attached to your window. Store the mouse position each time it fires and compare the current position to the last position to determine if you moved left, right, or not all all (i.e. up or down).
Upvotes: 1