views:

42

answers:

1

Hello! I am working on a limited remote control of another PC over network. At first the controlled window is chosen and the client may control that window and all child windows. I am having a problem with the mouse though, I can move it using SetCursorPos, but when I try to send the WM_LBUTTONDOWN and WM_LBUTTONUP messages, there is no result. I believe it's necessary for the window to be in the foreground first, but I am uncertain if SetForegroundWindow does exactly what happens after a click before the WM_ message is posted. Do you know how I can send a mouseclick directly to the window (if it's not a child window of a particular HWND, it's not allowed to be clicked). Thank you in advance.

Regards, Neo_b

+2  A: 

It may be better (and possibly easier) to use SendInput. I believe that is the recommended way to mimic a user using the mouse, instead of trying to mess with window messages directly.

TheUndeadFish
That goes to the window with the focus.
Hans Passant
Ok, thanks, but I'll probably have to add extra validation.
Neo_b