Why the mouse is moving on the lower right?

This is my code:

#define WINVER 0x0500
#include <windows.h>


void MouseMove (int x, int y )
{
double fScreenWidth = ::GetSystemMetrics( SM_CXSCREEN )-1;
double fScreenHeight = ::GetSystemMetrics( SM_CYSCREEN )-1;
double fx = x*(65535.0f/fScreenWidth);
double fy = y*(65535.0f/fScreenHeight);
INPUT Input={0};
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_MOVE;
Input.mi.dx = fx;
Input.mi.dy = fy;
::SendInput(1,&Input,sizeof(INPUT));
}


int main()
{

Sleep(3000);
MouseMove(1500,100);
Sleep(3000);
MouseMove(100,400);
system("pause");
return 0;
}

The pointer is always sitting lower right position whatever maybe the values of X and Y.
Why?
no idea. Why not print a short log file, say 10 seconds or so, of your actual commands (the values sent to sendinput) to see what it is doing?

MOUSEEVENTF_ABSOLUTE
0x8000

The dx and dy members contain normalized absolute coordinates. If the flag is not set, dx and dy contain relative data (the change in position since the last reported position). This flag can be set, or not set, regardless of what kind of mouse or other pointing device, if any, is connected to the system. For further information about relative mouse motion, see the following Remarks section.

https://msdn.microsoft.com/en-us/library/windows/desktop/ms646273(v=vs.85).aspx
Topic archived. No new replies allowed.