Jump to content

_WinAPI_SystemParametersInfo - get and set mouse speed


Recommended Posts

#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)

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

@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 by lee321987
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...