Search code examples
.netwindowskeyboardmouse

Where do I start if I want to program something that can change the configuration of Keyboard/Mouse in Windows?


Configuration as in the options you see in the Keyboard/Mouse settings under Windows. I have some .NET programming experience.


Solution

  • Win-API is your friend here. Google this API for more information, with this you can retrieve and set a lots of systems parameters about mouse and keyboad:

    SystemParametersInfo
    The SystemParametersInfo function queries or sets systemwide parameters. This function can also update the user profile while setting a parameter.

    Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
    

    If you for example send the uAction SPI_GETKEYBOARDDELAY to the function you will retrieve the keyboard repeat-delay setting. The pvParam parameter must point to an integer variable that receives the setting.

    Some other (there are more) intreresting constants are:
    GET:
    SPI_GETMOUSE, SPI_GETMOUSEHOVERHEIGHT, SPI_GETMOUSEHOVERTIME, SPI_GETMOUSEHOVERWIDTH, SPI_GETMOUSEKEYS, SPI_GETMOUSETRAILS, SPI_GETNONCLIENTMETRICS, SPI_GETSTICKYKEYS, SPI_GETTOGGLEKEYS, SPI_GETWHEELSCROLLLINES

    SET:
    SPI_SETDOUBLECLICKTIME, SPI_SETDOUBLECLKHEIGHT, SPI_SETDOUBLECLKWIDTH, SPI_SETKEYBOARDDELAY, SPI_SETKEYBOARDPREF, SPI_SETKEYBOARDSPEED, SPI_SETLANGTOGGLE, SPI_SETMOUSE, SPI_SETMOUSEBUTTONSWAP, SPI_SETMOUSEHOVERHEIGHT, SPI_SETMOUSEHOVERTIME, SPI_SETMOUSEHOVERWIDTH, SPI_SETMOUSEKEYS, SPI_SETMOUSETRAILS