octalmage / robotjs

Node.js Desktop Automation.
http://robotjs.io
MIT License
12.37k stars 961 forks source link

Question: Relative mouse move instead of Absolute #504

Closed polhaghverdian closed 4 years ago

polhaghverdian commented 5 years ago

Hi,

can anyone help me, how the implemention for Relative mouse move would be?

Below is from the source code, for Absolute mouse move:

`//Mouse motion is now done using SendInput with MOUSEINPUT. We use Absolute mouse positioning
    #define MOUSE_COORD_TO_ABS(coord, width_or_height) (((65536 * coord) / width_or_height) + (coord < 0 ? -1 : 1))
    point.x = MOUSE_COORD_TO_ABS(point.x, GetSystemMetrics(SM_CXSCREEN));
    point.y = MOUSE_COORD_TO_ABS(point.y, GetSystemMetrics(SM_CYSCREEN));
    INPUT mouseInput;
    mouseInput.type = INPUT_MOUSE;
    mouseInput.mi.dx = point.x;
    mouseInput.mi.dy = point.y;
    mouseInput.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
    mouseInput.mi.time = 0; //System will provide the timestamp
    mouseInput.mi.dwExtraInfo = 0;
    mouseInput.mi.mouseData = 0;
    SendInput(1, &mouseInput, sizeof(mouseInput));`
oktapodia commented 4 years ago

This issue has been closed because it has been inactive for > 90 days. You may reopen this issue if it has been closed in error.