lee321987 Posted February 9, 2020 Posted February 9, 2020 Would some kind soul please show me an example of how to retrieve and to set the current mouse speed using _WinAPI_SystemParametersInfo I know these values "SPI_GETMOUSE" and "SPI_SETMOUSE" fromhttps://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-systemparametersinfoa will be needed, but I am LOST in this DLL stuff.
Musashi Posted February 10, 2020 Posted February 10, 2020 #Include <WinAPI.au3> Global Const $SPI_GETMOUSESPEED = 112 ; 0x0070 Global Const $SPI_SETMOUSESPEED = 113 ; 0x0071 ; Get individual setting : Global $g_tMouseSpeed = DllStructCreate('int Speed') _WinAPI_SystemParametersInfo($SPI_GETMOUSESPEED, 0, DllStructGetPtr($g_tMouseSpeed), 0) ConsoleWrite("MouseSpeed (individual) = " & $g_tMouseSpeed.Speed & @CRLF) ; Info : value ranges between 1 (slowest) and 20 (fastest) - 10 is the default ; 1. Set speed to 1 = 'slowest' (for 4 sec.) _WinAPI_SystemParametersInfo($SPI_SETMOUSESPEED, 0, 1, 2) ConsoleWrite("MouseSpeed = 1 ('slowest')" & @CRLF) Sleep(4000) ; 2. Set speed to 20 = 'fastest' (for 4 sec.) _WinAPI_SystemParametersInfo($SPI_SETMOUSESPEED, 0, 20, 2) ConsoleWrite("MouseSpeed = 20 ('fastest')" & @CRLF) Sleep(4000) ; 3. Set speed back to individual setting _WinAPI_SystemParametersInfo($SPI_SETMOUSESPEED, 0, $g_tMouseSpeed.Speed, 2) pixelsearch, lee321987 and seadoggie01 3 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
lee321987 Posted February 11, 2020 Author Posted February 11, 2020 (edited) @Musashi Thank you very much! In your code, I think you meant to use the word "initial" instead of "individual". In case anyone else is trying to do this: With Musashi's code any changes to mouse speed affect the current session only (the settings will revert after a reboot). To make the changes permanent, change the last parameter from "2" to "1". i.e. change: _WinAPI_SystemParametersInfo($SPI_SETMOUSESPEED, 0, 10, 2) to _WinAPI_SystemParametersInfo($SPI_SETMOUSESPEED, 0, 10, 1) Edited February 11, 2020 by lee321987 pixelsearch 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now