how to script [CapsLock] / [NumLock] / [ScrollLock]

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
s_adavan
Posts: 62
Joined: 10 Nov 2020, 06:31

how to script [CapsLock] / [NumLock] / [ScrollLock]

Post by s_adavan » 27 Jun 2022, 22:38

Hi,
I came across this page about Capslock, Numlock and Scrolllock:
https://www.autohotkey.com/docs/commands/SetNumScrollCapsLockState.htm
but I don't quite understand it.

Question 1
If I want to disable the key, how should it be written, is it like this:

Code: Select all

Numlock:: 
SetNumLockState, Off
return
If I simply write it like this below, is there any difference, is it the proper way?

Code: Select all

numlock:: return

Question 2
If I want to hotkey, can I simply write it like this:

Code: Select all

$Numlock:: 	Send, ^+{i}		;Screenshot
or is it like this?

Code: Select all

$Numlock:: 
SetNumLockState, Off
Send, ^+{i}	;Screenshot
return	

If these are not correct, please kindly enlighten how is the proper way.

thank you.
There is nothing impossible to him who will try. -Alexander the Great-

User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: how to script [CapsLock] / [NumLock] / [ScrollLock]

Post by mikeyww » 28 Jun 2022, 05:49

A suggestion: you can answer these questions by running these scripts. It's an effective approach because it allows you to test your idea and confirm the results quickly, while you learn things along the way. That is what I usually do in a situation like this.

You might not need the dollar prefix here. See https://www.autohotkey.com/docs/Hotkeys.htm#prefixdollar. Again, easy to test by omitting it.

s_adavan
Posts: 62
Joined: 10 Nov 2020, 06:31

Re: how to script [CapsLock] / [NumLock] / [ScrollLock]

Post by s_adavan » 28 Jun 2022, 09:29

I see. ok.
I also found this decade old topic earlier:
https://www.autohotkey.com/board/topic/64436-remapping-numlock-key/

After my numpad broke down, I just become paranoid, second guessing everything that I wrote myself.

Thank you Mikey .. :)
There is nothing impossible to him who will try. -Alexander the Great-

Post Reply

Return to “Ask for Help (v1)”