Code: Select all
x::MouseSpeedToggleHold(1) ; change the speed here
MouseSpeedToggleHold(newSpeed) {
static GetMouseSpeed := 0x70
static SetMouseSpeed := 0x71
DllCall("SystemParametersInfo", "UInt", GetMouseSpeed, "UInt", 0, "UIntP", &originalSpeed:=0, "UInt", 0) ; Get the original speed
DllCall("SystemParametersInfo", "UInt", SetMouseSpeed, "UInt", 0, "UInt", newSpeed, "UInt", 0) ; set the new speed
KeyWait RegExReplace(A_ThisHotkey, "^.*(\w+)$", "$1") ; wait for this hotkey
DllCall("SystemParametersInfo", "UInt", SetMouseSpeed, "UInt", 0, "UInt", originalSpeed, "UInt", 0) ; restore the speed
}