i am trying to figure out what the api is for a simple left mouse click
ive got the cordinates set .
anyone help me?
i am trying to figure out what the api is for a simple left mouse click
ive got the cordinates set .
anyone help me?
Never tried it but WindowFromPoint and SendMessage with WM_LBUTTONDOWN/WM_LBUTTONUP should work.
i cant get this to workOriginally Posted by Quantum1024
SendMessage(WM_LBUTTONDOWN);
I managed to get it to work. PostMessage is realy a better solution since there's no need for the program to wait for the message to be handled.
Code:void Click(int x, int y) { POINT p; p.x=x; p.y=y; HWND hWnd=WindowFromPoint(p); if (ScreenToClient(hWnd, &p)) { PostMessage(hWnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELONG(p.x, p.y)); PostMessage(hWnd, WM_LBUTTONUP, 0, MAKELONG(p.x, p.y)); } }
thanks alot worksgreat
You can use mouse_event() too...
http://msdn.microsoft.com/library/de...ouse_event.asp
what would i use for arrowdown or arrowup or left and right ?
to press down these i mean
Wm_keydown/wm_keyup
its saying this
error C2660: 'PostMessageA' : function does not take 3 parameters
Code:void Click(int x, int y) { POINT p; p.x=x; p.y=y; HWND hWnd=WindowFromPoint(p); if (ScreenToClient(hWnd, &p)) { PostMessage(hWnd, WM_KEYDOWN, MK_LBUTTON, MAKELONG(p.x, p.y)); //WM_LBUTTONDOWN PostMessage(hWnd, WM_KEYDOWN, MAKELONG(p.x, p.y)); } }
In your second call to PostMessage you left out one paramater, also the wParam and lParam don't have the same meaning as with WM_LBUTTONDOWN and WM_LBUTTONUP.
take a look at this http://msdn.microsoft.com/library/de...wm_keydown.asp
i never seem to be able to understand msdn
is there a chance you could paste the code like you did from the other
You can send 1 up arrow keystroke like this.
Sending the down arrow key is left as an excercise.Code:PostMessage(hWnd, WM_KEYDOWN, VK_UP, 1);
7 C:\Dev-Cpp\main.cpp `hWnd' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)
void f()
{
PostMessage(hWnd, WM_KEYDOWN, VK_UP, 1);
}
void arrow(int x, int y)
{
POINT p;
p.x=x;
p.y=y;
HWND hWnd=WindowFromPoint(p);
if (ScreenToClient(hWnd, &p))
{
PostMessage(hWnd, WM_KEYDOWN, VK_UP, 1);
}
}