1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
int oldAccel[3], newAccel[3], oldSpeed, newSpeed, x, y;
BOOL bResult;
// The following values are for the mouse to move 1 pixel per mickey (a mickey is a unit for the smallest detectable movement of a mouse)
newAccel[0] = 0;
newAccel[1] = 0;
newAccel[2] = 0;
newSpeed = 1;
// Save the current settings for mouse speed and acceleration
bResult = SystemParametersInfo(SPI_GETMOUSE, 0, oldAccel, 0);
bResult = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &oldSpeed, 0);
// Set the mouse speed and acceleration to our constants
bResult = SystemParametersInfo(SPI_SETMOUSE, 0, newAccel, SPIF_SENDCHANGE);
bResult = SystemParametersInfo(SPI_SETMOUSESPEED, 0, &newSpeed, SPIF_SENDCHANGE);
// Set some arbitrary x and y coordinates
x = -100;
y = -150;
mouse_event(MOUSEEVENTF_ABSOLUTE, 0, 0, 0, 0);
// Move the mouse the top-left (origin) of the monitor screen
mouse_event(0, x, y, 0, 0);
// Move the cursor to the desired x and y coordinates
// Revert the mouse speed and acceleration settings to their original values
bResult = SystemParametersInfo(SPI_SETMOUSE, 0, oldAccel, SPIF_SENDCHANGE);
bResult = SystemParametersInfo(SPI_SETMOUSESPEED, 0, &oldSpeed, SPIF_SENDCHANGE);
| |