The following code allows you to simulate clicking of the mouse button programmatically.
It will remember the current cursor position, move to the coordinate to click, perform the click and restore the cursor position.
C++ source code.
===============
void ClickOnPoint(int x, int y)
{
POINT prevPt;
GetCursorPos(&prevPt);
SetCursorPos(x, y);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
SetCursorPos(prevPt.x, prevPt.y);
}
No comments:
Post a Comment