Is it possible to get the mouse moving direction even though the mouse doesn’t move on screen? For example it collides with an edge.
edit:
The user moves the mouse to the top and collides with the top edge of the screen.
Then he keeps on moving the mouse upwards. So the mouse moves in real world but doesn’t move on the screen cause it can’t. And I want to get a signal or anything else that tells me in which direction the mouse is moving atm.
As I see it, basically what you are asking is how you can detect a case where the mouse is on the edge of the screen and trying to move in the direction of the edge. Naturally, a
MouseMoveevent will not detect this because the coordinate has not changed.Using a global low level mouse hook is possibly the only way of getting a mouse move message even if the cursor has not changed position.
This allows to check if the coordinate has changed since the last message or not. If it has not, we might be at the edge of the screen.
*Hook code was taken from this blog
The problem with this method is that if the mouse is moving slower than 1 pixel per mouse message, a false positive is generated.
A possible partial solution to this would be to pre-detect the X and Y values of screen edges and test for those as well, but even this will not eliminate 100% of false positives, as it is possible for the mouse to be (for example) on the right edge of the screen and move very slowly left (less than 1 pixel), and this would still be detected as a positive.
Perhaps someone has a better idea how to eliminate these false positives.