C ++ Position on the screen looks strange when I try to convert from GetCursorPos to SendInputs

0

I used the GetCursorPos function to get some positions on the screen that I would like the mouse to be able to click to perform a task for me and automate the service.

I tried to select these positions with SetCursorPos and it worked, however the program I use needs to be fullscreen and the SetCursorPos function does not work, so I used the SendInput function, but the same coordinates look different.

Here is the code for part of 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;
}

Follow the function that acquired the positions on the screen.

POINT P;
GetCursorPos(&P);

Clearly this requires some kind of coordinate conversion but I can not do that.

    
asked by anonymous 21.11.2018 / 03:00

0 answers