How to set the mouse pointer to pointer precision

How to adjust mouse cursor with increasing pointer accuracy in C ++? I know that there are some useful commands, such as SystemParametersInfo, for speed, ...

int x = 15; 

SystemParametersInfo (SPI_SETMOUSESPEED, NULL, reinterpret_cast (x), SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);

... but I cannot find an increase in accuracy ----

+3
source share
3 answers

According to the documentation for the SystemParametersInfo and SPI_SETMOUSE :

Sets two mouse thresholds and mouse acceleration. The pvParam parameter must point to an array of three integers that sets these values. See mouse_event for more details.

So, you need an array containing 3 values, and you point to this array as the pvParam parameter when calling SystemParametersInfo .

Since all you care about is changing the acceleration (the last value), you probably want to keep the current values ​​for the first two values ​​of the mouse threshold. Do this by calling SystemParametersInfo with the SPI_GETMOUSE flag to get these values, then changing the last (acceleration), and then calling SystemParametersInfo again, this time with the SPI_SETMOUSE flag.

Sample code (no recommendation for error checking):

 // Turns mouse acceleration on/off by calling the SystemParametersInfo function. // When mouseAccel is TRUE, mouse acceleration is turned on; FALSE for off. void SetMouseAcceleration(BOOL mouseAccel) { int mouseParams[3]; // Get the current values. SystemParametersInfo(SPI_GETMOUSE, 0, mouseParams, 0); // Modify the acceleration value as directed. mouseParams[2] = mouseAccel; // Update the system setting. SystemParametersInfo(SPI_SETMOUSE, 0, mouseParams, SPIF_SENDCHANGE); } 

And you probably already know this, but there are too many poorly managed applications so I don't mention it just in case. If you do this in your application, be sure to keep the original value to restore it when your application is closed! This is a simple basic etiquette when changing system-wide settings.

+7
source

"Increase pointer accuracy" is an option to accelerate on / off.

The SPI_SETMOUSE parameter for SystemParametersInfo will adjust this setting.

I can’t say for sure how the acceleration values ​​affect, but if you are SPI_GETMOUSE and display the values ​​with the parameter on and off, you will find it.

+1
source

This discussion contains a bit more information. It has a macro that seems to do what you are looking for. Converting to C ++ should be pretty simple; these are just a couple of dll calls.

+1
source

Source: https://habr.com/ru/post/1383818/


All Articles