I have the code below and know that it is used to move the mouse cursor to a specific point on the screen.
The thing I do not understand is why the X and Y coordinates must be multiplied by 65535 and divided by the size of the screen.
Does it have anything to do with the conversion from a float to an integer type?
public void MoveMouse(PointF p)
{
if (IntPtr.Size == 8)
{
var move = new INPUT64[1];
move[0] = new INPUT64();
move[0].mi.dx = (int)(p.X * 65535 / ScreenSize.Width);
move[0].mi.dy = (int)(p.Y * 65535 / ScreenSize.Height);
move[0].mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
SendInput(1, move, Marshal.SizeOf(move[0]));
}
else
{
var move = new INPUT32[1];
move[0] = new INPUT32();
move[0].mi.dx = (int)(p.X * 65535 / ScreenSize.Width);
move[0].mi.dy = (int)(p.Y * 65535 / ScreenSize.Height);
move[0].mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
SendInput(1, move, Marshal.SizeOf(move[0]));
}
}