windows api控制鼠标移动的快慢

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/xinpo66/article/details/97168855

电脑上可以通过控制面板的鼠标来设置,我把设置为最慢,忽然感觉像是遇到了疯狂动物城里面的闪电~ 别提有多慢了。

如何用代码控制呢? 

函数 SystemParametersInfo 
参考网址  https://technet.microsoft.com/zh-cn/scriptcenter/ms724947(v=vs.95)

后面的那个例子说的就是鼠标移动快慢的。

#include <windows.h>
#include <stdio.h>
#pragma comment(lib, "user32.lib")    

void main()  
{     
    BOOL fResult;
    int aMouseInfo[3];    // Array for mouse information
    
    // Get the current mouse speed.         
    fResult = SystemParametersInfo(SPI_GETMOUSE,   // Get mouse information
                                   0,              // Not used
                                   &aMouseInfo,    // Holds mouse information
                                   0);             // Not used           
                                   
    // Double it.         
    if( fResult )     
    {
        aMouseInfo[2] = 2 * aMouseInfo[2];
        
        // Change the mouse speed to the new value.
        SystemParametersInfo(SPI_SETMOUSE,      // Set mouse information
                             0,                 // Not used
                             aMouseInfo,        // Mouse information
                             SPIF_SENDCHANGE);  // Update Win.ini
    }  
}

猜你喜欢

转载自blog.csdn.net/xinpo66/article/details/97168855
今日推荐