如何以编程方式配置鼠标以提高指针精度 [英] How to configure mouse enhance pointer precision programmatically

查看:116
本文介绍了如何以编程方式配置鼠标以提高指针精度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在C ++中以编程方式配置鼠标增强指针精度? 我知道有一些有用的命令,例如SystemParametersInfo,可以提高速度,...

How to configure mouse enhance pointer precision programmatically in C++? I know that have some useful commands like SystemParametersInfo, for speed, ...

int x = 15;

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

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

...但是我找不到增强精度----

... but I cannot find enhance precision----

推荐答案

根据 SystemParametersInfo函数和SPI_SETMOUSE的文档:

According to the documentation for the SystemParametersInfo function and SPI_SETMOUSE:

设置两个鼠标阈值和鼠标加速度. pvParam参数必须指向指定这些值的三个整数的数组.有关更多信息,请参见 mouse_event .

Sets the two mouse threshold values and the mouse acceleration. The pvParam parameter must point to an array of three integers that specifies these values. See mouse_event for further information.

因此,您需要一个包含3个值的数组,并在调用SystemParametersInfo时将指向该数组的指针指定为pvParam参数.

So you need an array containing 3 values, and you specify a pointer to that array as the pvParam parameter when calling SystemParametersInfo.

由于您关心的只是更改加速度(最后一个值),因此您可能希望保留前两个鼠标阈值的 current 值.为此,请使用SPI_GETMOUSE标志调用SystemParametersInfo以获取这些值,然后修改最后一个值(加速度),然后再次使用SPI_SETMOUSE标志调用SystemParametersInfo.

Since all you care about is changing the acceleration (the last value), you probably want to retain the current values for the first two, the mouse threshold values. Do that by calling SystemParametersInfo with the SPI_GETMOUSE flag to obtain those values, then modifying the last one (the acceleration), and then calling SystemParametersInfo again, this time with the SPI_SETMOUSE flag.

示例代码(不建议进行错误检查):

Sample code (without recommended 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 badly-behaved applications out there for me not to mention it just in case. If you're doing this in your application, be sure to save the original value so that you can restore it when your app is closed! This is just basic etiquette when you're modifying system-wide settings.

这篇关于如何以编程方式配置鼠标以提高指针精度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆