Slow Down mouse speed while holding down f & Space

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
akirofe
Posts: 149
Joined: 05 Apr 2021, 21:54

Slow Down mouse speed while holding down f & Space

27 May 2021, 20:55

Hi gurus,

I really hope you could help me with this.

I wanted to slow down my mouse while holding f & Space down, and luckily found a code that worked when I tried LWin (below), but didn't for f & Space (below). Please kindly help me guys.

Love our community!!

Code: Select all

; SlowDown

LWin::

SPI_GETMOUSESPEED = 0x70

SPI_SETMOUSESPEED = 0x71

DllCall("SystemParametersInfo", UInt, SPI_GETMOUSESPEED, UInt, O, UIntP, OrigMouseSpeed, UInt, 0)

DllCall("SystemParametersInfo", UInt, SPI_SETMOUSESPEED, UInt, O, UInt, 1, UInt, 0)

Keywait LWin

return

LWin up::DllCall("SystemParametersInfo", UInt, 0x71, UInt, O, UInt, OrigMouseSpeed, UInt, 0)


; SlowDown

f & Space::

SPI_GETMOUSESPEED = 0x70

SPI_SETMOUSESPEED = 0x71

DllCall("SystemParametersInfo", UInt, SPI_GETMOUSESPEED, UInt, O, UIntP, OrigMouseSpeed, UInt, 0)

DllCall("SystemParametersInfo", UInt, SPI_SETMOUSESPEED, UInt, O, UInt, 1, UInt, 0)

Keywait f & Space

return

f & Space up::DllCall("SystemParametersInfo", UInt, 0x71, UInt, O, UInt, OrigMouseSpeed, UInt, 0)
[Mod edit: [code][/code] tags added.]
Rohwedder
Posts: 7622
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Slow Down mouse speed while holding down f & Space

28 May 2021, 02:26

Hallo,
try:

Code: Select all

f & Space:: ; SlowDown
;SPI_GETMOUSESPEED = 0x70, SPI_SETMOUSESPEED = 0x71
DllCall("SystemParametersInfo", "UInt", 0x70, "UInt", O, "UIntP", OrigMouseSpeed, "UInt", 0)
DllCall("SystemParametersInfo", "UInt", 0x71, "UInt", O, "UInt", 1, "UInt", 0)
KeyWait, f
~Space Up::
If OrigMouseSpeed
	DllCall("SystemParametersInfo", "UInt", 0x71, "UInt", O, "UInt", OrigMouseSpeed, "UInt", 0)
OrigMouseSpeed =
Return
akirofe
Posts: 149
Joined: 05 Apr 2021, 21:54

Re: Slow Down mouse speed while holding down f & Space

30 May 2021, 22:26

You. Are. A. Legend!!

( I'm an architect but love to push boundaries... My Whatsapp/Viber/mobile number is +61420946997 if you are seeking a smart person to talk to like I do. Love your work man!!! )

PS. If you could also kindle help... I'm posting another question asking why adding more {WheelUP} doesn't speed it up when I hit a & d to scroll the mouse wheel (code below)? Thank you soooo much!!

a & d::
send {WheelUp}{WheelUp}{WheelUp}{WheelUp}{WheelUp}{WheelUp}{WheelUp}
return
akirofe
Posts: 149
Joined: 05 Apr 2021, 21:54

Re: Slow Down mouse speed while holding down f & Space

30 May 2021, 22:44

Sorry, continued to my last reply, I just noticed the mouse wheel does speed up in Chrome but not in Notepad which was why my last post. Thank you!!!
Rohwedder
Posts: 7622
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Slow Down mouse speed while holding down f & Space

31 May 2021, 02:22

Some programs e.g. Browser and Microsoft Office (but not Notepad or Notepad++) consider SystemParameters.WheelScrollLines Property
Gets a value that indicates the number of lines to scroll when the mouse wheel is rotated.
I use this sniped to set that value:

Code: Select all

<!WheelUp:: ;LAlt + Wheel Up/Down
<!WheelDown:: ;Set WheelScrollLines: 1-5
SendInput, {Blind}{vkE8} ;prevents activation of menu bar
;HKEY_CURRENT_USER\Control Panel\Desktop: WheelScrollLines
ToolTip,% "Wheel (1-5): " Wheel:=Max(Min(0 Wheel+2*(A_ThisHotkey="<!WheelUp")-1,5),1)
SetTimer, RemoveToolTip, -1000
DllCall("SystemParametersInfoA","uint",0x69,"uint",Wheel,"uintP",0,"uint",1|2)
Return
~*LWin::SendInput,% A_PriorKey="LWin"?:"{Blind}{vkE8}"
RemoveToolTip:
ToolTip
Return
akirofe
Posts: 149
Joined: 05 Apr 2021, 21:54

Re: Slow Down mouse speed while holding down f & Space

14 Jun 2021, 00:55

Rohwedder wrote:
31 May 2021, 02:22
Some programs e.g. Browser and Microsoft Office (but not Notepad or Notepad++) consider SystemParameters.WheelScrollLines Property
Gets a value that indicates the number of lines to scroll when the mouse wheel is rotated.
I use this sniped to set that value:

Code: Select all

<!WheelUp:: ;LAlt + Wheel Up/Down
<!WheelDown:: ;Set WheelScrollLines: 1-5
SendInput, {Blind}{vkE8} ;prevents activation of menu bar
;HKEY_CURRENT_USER\Control Panel\Desktop: WheelScrollLines
ToolTip,% "Wheel (1-5): " Wheel:=Max(Min(0 Wheel+2*(A_ThisHotkey="<!WheelUp")-1,5),1)
SetTimer, RemoveToolTip, -1000
DllCall("SystemParametersInfoA","uint",0x69,"uint",Wheel,"uintP",0,"uint",1|2)
Return
~*LWin::SendInput,% A_PriorKey="LWin"?:"{Blind}{vkE8}"
RemoveToolTip:
ToolTip
Return
You. Are. A. Legend. Again!!

Thank you very much Rohwedder!!
momo007
Posts: 12
Joined: 13 Jul 2019, 09:06

Re: Slow Down mouse speed while holding down f & Space

19 Jan 2023, 12:34

hi, looking for a similar code, here.
How can I change the code so that when I'm in ONENOTE (and onenote only),
WheelScrollLines = 2.
(it's 15 in normal mode)

THANKS
Rohwedder
Posts: 7622
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Slow Down mouse speed while holding down f & Space

20 Jan 2023, 03:44

Hallo,
I suppose you want 5 (not 15) in normal mode. Try:

Code: Select all

$WheelUp::
$WheelDown::
SetTitleMatchMode 2
MouseGetPos,,, ID
(Wh0<>Wh1:=WinExist("‎- OneNote ahk_id" ID)?2:5)?DllCall("SystemParametersInfoA"
	,"uint",0x69,"uint",Wh0:=Wh1,"uintP",0,"uint",1|2):
SendInput,% "{" SubStr(A_ThisHotkey, 2) "}"
Return
momo007
Posts: 12
Joined: 13 Jul 2019, 09:06

Re: Slow Down mouse speed while holding down f & Space

20 Jan 2023, 05:50

Thank you :bravo:

It actually does something (we're getting there:)), the code changes the value of scroll lines to 5,
but when I get out ONENOTE it stays at 5 (need it to be 15 or any other value to choose ),
(look like it changes the value globally to 5)

Code: Select all

#IfWinActive ahk_exe ONENOTE.exe

$WheelUp::
$WheelDown::
SetTitleMatchMode 2
MouseGetPos,,, ID
(Wh0<>Wh1:=WinExist("?- OneNote ahk_id" ID)?2:5)?DllCall("SystemParametersInfoA"
	,"uint",0x69,"uint",Wh0:=Wh1,"uintP",0,"uint",1|2):
SendInput,% "{" SubStr(A_ThisHotkey, 2) "}"
Return
Rohwedder
Posts: 7622
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Slow Down mouse speed while holding down f & Space

21 Jan 2023, 04:17

Then:

Code: Select all

$WheelUp::
$WheelDown::
WOn = 2  ;WheelScrollLines Onenote
WOw = 15 ;WheelScrollLines Otherwise
SetTitleMatchMode 2
MouseGetPos,,, ID
(Wh0<>Wh1:=WinExist("‎- OneNote ahk_id" ID)?WOn:WOw)?DllCall("SystemParametersInfoA"
	,"uint",0x69,"uint",Wh0:=Wh1,"uintP",0,"uint",1|2):
SendInput,% "{" SubStr(A_ThisHotkey, 2) "}"
Return
momo007
Posts: 12
Joined: 13 Jul 2019, 09:06

Re: Slow Down mouse speed while holding down f & Space

22 Jan 2023, 12:29

I don't know why but it is not working for me.
it stays on 15 now (globally).

thank you very much for your time and effort :clap:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Rohwedder and 339 guests