windows api控制鼠標移動的快慢

電腦上可以通過控制面板的鼠標來設置,我把設置爲最慢,忽然感覺像是遇到了瘋狂動物城裏面的閃電~ 別提有多慢了。

如何用代碼控制呢? 

函數 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
    }  
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章