How can I determine if we are moving both inside and outside the borders of my window in WPF / C #?

I have a small video application that I would like to provide vlc-like functions. By this I mean that some element disappears and appears when you move the mouse or mouse without moving. I have a rough idea of ​​how to do this, but I have no idea how I can determine if the mouse is moving or not. I was thinking about using the GetPosition function, but that just gives me the mouse position and won't let me know if the cursor is moving or not. I would like to use a timer to count down 2-3 seconds after the mouse stops moving, and then either disappears out of control, or just make it crash without further ado. I cannot check the value of a variable position every milliseconds. Is there any other way to do this?

+4
source share
2 answers

You can use the hook functionality so that you are notified when the mouse moves, I use this free openource library.

How to use it:

using Gma.UserActivityMonitor.GlobalEventProvider; GlobalEventProvider _globalEventProvider1 = new Gma.UserActivityMonitor.GlobalEventProvider(); this.globalEventProvider1.MouseMove += HookMouseMove;//to listen to mouse move 
+3
source

Mouse capture. Release the capture if the user really clicks elsewhere. Then you can use the standard WPF mouse move event.

 myElement.MouseMove += (my MouseMove handler) Mouse.Capture(myElement); 
0
source

All Articles