</head> <body> <h1>SetCapsLockState / SetNumLockState / SetScrollLockState</h1> <p>Sets the state of <kbd>CapsLock</kbd>/<kbd>NumLock</kbd>/<kbd>ScrollLock</kbd>. Can also force the key to stay on or off.</p> <pre class="Syntax"> <span class="func">SetCapsLockState</span> <span class="optional">, State</span> <span class="func">SetNumLockState</span> <span class="optional">, State</span> <span class="func">SetScrollLockState</span> <span class="optional">, State</span> </pre> <h2 id="Parameters">Parameters</h2> <dl> <dt>State</dt> <dd><p>If this parameter is omitted, the AlwaysOn/Off attribute of the key is removed (if present). Otherwise, specify one of the following words:</p> <p><strong>On</strong>: Turns on the key and removes the AlwaysOn/Off attribute of the key (if present).</p> <p><strong>Off</strong>: Turns off the key and removes the AlwaysOn/Off attribute of the key (if present).</p> <p><strong>AlwaysOn</strong>: Forces the key to stay on permanently.</p> <p><strong>AlwaysOff</strong>: Forces the key to stay off permanently.</p> <p><span class="ver">[v1.1.30+]:</span> The decimal values 1 and 0 may be used in place of On and Off, respectively.</p> </dd> </dl> <h2 id="Remarks">Remarks</h2> <p>Alternatively to <a href="#ExToggle">example #3</a> below, a key can also be toggled to its opposite state via the <a href="Send.htm">Send</a> command; for example: <code>Send {CapsLock}</code>. However, sending {CapsLock} might require <code><a href="SetStoreCapslockMode.htm">SetStoreCapsLockMode</a> Off</code> beforehand.</p> <p>Keeping a key <em>AlwaysOn</em> or <em>AlwaysOff</em> requires the <a href="_InstallKeybdHook.htm">keyboard hook</a>, which will be automatically installed in such cases.</p> <h2 id="Related">Related</h2> <p><a href="SetStoreCapslockMode.htm">SetStoreCapsLockMode</a>, <a href="GetKeyState.htm#function">GetKeyState()</a></p> <h2 id="Examples">Examples</h2> <div class="ex" id="ExBasic"> <p><a class="ex_number" href="#ExBasic"></a> Turns on <kbd>NumLock</kbd> and removes the AlwaysOn/Off attribute of the key (if present).</p> <pre>SetNumLockState, On</pre> </div> <div class="ex" id="ExAlwaysOff"> <p><a class="ex_number" href="#ExAlwaysOff"></a> Forces <kbd>ScrollLock</kbd> to stay off permanently.</p> <pre>SetScrollLockState, AlwaysOff</pre> </div> <div class="ex" id="ExToggle"> <p><a class="ex_number" href="#ExToggle"></a> Toggles <kbd>CapsLock</kbd> to its opposite state.</p> <pre>SetCapsLockState % !GetKeyState("CapsLock", "T") <em>; requires <span class="ver">[v1.1.30+]</span></em></pre> </div> </body> </html>