0
I used the function GetCursorPos
to pick up positions on the screen I would like the mouse to be able to click to perform a task for me and automate the service.
I tested selecting these positions with the SetCursorPos
and it worked, however the program using needs to be fullscreen and function SetCursorPos
does not work, so I used the function SendInput
but the same coordinates seem different.
Follow the code from the SendInput
:
inline bool mouse_move(int x, int y)
{
INPUT input;
input.type = INPUT_MOUSE;
input.mi.mouseData = 0;
input.mi.time = 0;
input.mi.dx = (x + 1) * (65535 / GetSystemMetrics(SM_CXSCREEN));//x being coord in pixels
input.mi.dy = (y + 1) * (65535 / GetSystemMetrics(SM_CYSCREEN));//y being coord in pixels
input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP;
SendInput(1, &input, sizeof(input));
return true;
}
Follows the function I got the positions on the screen.
POINT P;
GetCursorPos(&P);
Clearly this requires some kind of coordinate conversion but I cannot accomplish such a thing.
"however the program that use needs to be fullscreen and the Setcursorpos function does not work " Gave some error ? did not give the values you intended ? What happened ?
– Isac
It does not move the mouse, simply ignores the function, while the sendinput it moves the mouse but the positioning gets wrong.
– Patrick Machado