SetCapsLockState / SetNumLockState / SetScrollLockState

Sets the state of the CapsLock/NumLock/ScrollLock key. Can also force the key to stay on or off.

SetCapsLockState , State
SetNumLockState , State
SetScrollLockState , State

Parameters

State

If this parameter is omitted, the AlwaysOn/Off attribute of the key is removed (if present). Otherwise, specify one of the following words:

On: Turns on the key and removes the AlwaysOn/Off attribute of the key (if present).

Off: Turns off the key and removes the AlwaysOn/Off attribute of the key (if present).

AlwaysOn: Forces the key to stay on permanently.

AlwaysOff: Forces the key to stay off permanently.

[v1.1.30+]: The decimal values 1 and 0 may be used in place of On and Off, respectively.

Remarks

Alternatively to example #2 below, a key can also be toggled to its opposite state via the Send command; for example: Send {CapsLock}. However, sending {CapsLock} might require SetStoreCapsLockMode Off beforehand.

Keeping a key AlwaysOn or AlwaysOff requires the keyboard hook, which will be automatically installed in such cases.

Related

SetStoreCapsLockMode, GetKeyState

Examples

Example #1: Miscellaneous

SetNumLockState, On
SetScrollLockState, AlwaysOff

Example #2

Toggles CapsLock to its opposite state:

SetCapsLockState % !GetKeyState("CapsLock", "T") ; requires [v1.1.30+]