Article ID: 193003
Article Last Modified on 7/11/2005
// Visual C++ 5.0 does not define these constants. Visual C++ 6.0 does,
// so you need to allow for both possibilities.
#ifndef SPI_GETMOUSESPEED
#define SPI_GETMOUSESPEED 112
#endif
#ifndef SPI_SETMOUSESPEED
#define SPI_SETMOUSESPEED 113
#endif
int oldAccel[3], newAccel[3], oldSpeed, newSpeed, x, y;
BOOL bResult;
// The following values set mouse ballistics to 1 mickey/pixel.
newAccel[0] = 0;
newAccel[1] = 0;
newAccel[2] = 0;
newSpeed = 1;
// Save the Current Mouse Acceleration Constants
bResult = SystemParametersInfo(SPI_GETMOUSE,0, oldAccel,0);
bResult = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &oldSpeed,0);
// Set the new Mouse Acceleration Constants (Disabled).
bResult = SystemParametersInfo(SPI_SETMOUSE, 0, newAccel,
SPIF_SENDCHANGE);
bResult = SystemParametersInfo(SPI_SETMOUSESPEED, 0, newSpeed,
SPIF_SENDCHANGE);
//Pick some arbitrary x & y values.
x = -100;
y = -150;
// Move cursor to UL of primary monitor (origin).
mouse_event(MOUSEEVENTF_ABSOLUTE,0,0,0,0);
// Move the cursor to the desired coordinates.
mouse_event(0,x,y,0,0);
// Restore the old Mouse Acceleration Constants.
bResult = SystemParametersInfo(SPI_SETMOUSE,0, oldAccel,
SPIF_SENDCHANGE);
bResult = SystemParametersInfo(SPI_SETMOUSESPEED, 0, oldSpeed,
SPIF_SENDCHANGE);
Keywords: kbinput kbprb kbfaq kbcode KB193003