Is there anyway to force a mouse click using C++ outside of my application? For example, if a mouse is in a certain coordinate, it is forced to click.
-
Within your own application, or any on the system?Linuxios– Linuxios2012-07-07 23:12:18 +00:00Commented Jul 7, 2012 at 23:12
-
For that, you probably want to write a mouse driver-esque thing.Linuxios– Linuxios2012-07-07 23:13:48 +00:00Commented Jul 7, 2012 at 23:13
-
Some sort of driver that tells the system that the mouse has clicked somewhere (even if it hasn't). For that, you need to write a driver. Bit of overkill, eh? I'm sure there is a better solution, I just don't know what it is.Linuxios– Linuxios2012-07-07 23:18:46 +00:00Commented Jul 7, 2012 at 23:18
-
@Linuxios I don't want to know if the mouse has clicked somewhere, I want to make it click somewhereLiam McInroy– Liam McInroy2012-07-07 23:20:50 +00:00Commented Jul 7, 2012 at 23:20
-
2I understand that. If you made a pretend driver, it could send mouse click events to the system without there actually being a mouse click. Great opportunity for malware, eh?Linuxios– Linuxios2012-07-07 23:31:41 +00:00Commented Jul 7, 2012 at 23:31
Add a comment
|
2 Answers
Try this:
HWND h = (hwnd of window)
WORD mouseX = 10;// x coord of mouse
WORD mouseY = 10;// y coord of mouse
PostMessage(hWnd,WM_LBUTTONDOWN,0,MAKELPARAM(mouseX,mouseY));
Taken from this site.