Getting mouse click outside form
-
I need to get the coordinates of a click outside of my form, can anybody show me a quick example of doing this?
If you can interop it, there's a method for capturing the mouse so that you can get the first click, otherwise you need a system wide hook to catch mouse activity outside your form. Christian Graus - Microsoft MVP - C++
-
If you can interop it, there's a method for capturing the mouse so that you can get the first click, otherwise you need a system wide hook to catch mouse activity outside your form. Christian Graus - Microsoft MVP - C++
-
-
-
The SetCapture API is the only way outside of a global windows hook to capture the mouse at all outside your window. I'm not sure you can write a global hook in C#. Christian Graus - Microsoft MVP - C++
-
The SetCapture API is the only way outside of a global windows hook to capture the mouse at all outside your window. I'm not sure you can write a global hook in C#. Christian Graus - Microsoft MVP - C++
I'm using this code to get the mouse position with a timer interval of 10, and it works fine, I'm just not familar with the api enough to figure out how to check for clicks
[DllImport("user32.dll")] static extern bool GetCursorPos(ref Point lpPoint); private void timer1_Tick(object sender, System.EventArgs e) { Point defPnt = new Point(); GetCursorPos(ref defPnt); MouseX = defPnt.X; MouseY = defPnt.Y; }
-
I'm using this code to get the mouse position with a timer interval of 10, and it works fine, I'm just not familar with the api enough to figure out how to check for clicks
[DllImport("user32.dll")] static extern bool GetCursorPos(ref Point lpPoint); private void timer1_Tick(object sender, System.EventArgs e) { Point defPnt = new Point(); GetCursorPos(ref defPnt); MouseX = defPnt.X; MouseY = defPnt.Y; }
Yes, you can query where the mouse is at any time, perhaps there is an API like it you can call to get the button state. Christian Graus - Microsoft MVP - C++
-