1

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.

5
  • Within your own application, or any on the system? Commented Jul 7, 2012 at 23:12
  • For that, you probably want to write a mouse driver-esque thing. Commented 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. Commented 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 somewhere Commented Jul 7, 2012 at 23:20
  • 2
    I 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? Commented Jul 7, 2012 at 23:31

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

this should do fine:

http://www.cplusplus.com/forum/lounge/17053/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.