(view source code of keylocks.bat as plain text)
D 0:417 L 1
:: Check the command line arguments
:: Run DEBUG with the temporary script and capture the result
:: Calculate the status of the individual keys
SET /A CapsLock = "(%KeyLocks% & 0x40) / 0x40"
SET /A NumLock = "(%KeyLocks% & 0x20) / 0x20"
SET /A ScrollLock = "(%KeyLocks% & 0x10) / 0x10"
:: Display the requested result(s)
:: Default return code is the combined status
SET /A KeyLocks = "%KeyLocks% & 0x70"
:: If a single key lock was requested on the command
:: line, the return code will be that key's status
:: Return the requested key lock's status as "errorlevel"
EXIT /B %KeyLocks%
ECHO Return the status of the CapsLock, NumLock and ScrollLock keys
ECHO Notes: The status of either the requested or all key lock(s) is displayed
ECHO NumLock and ScrollLock. The value of the environment variable
ECHO KeyLocks, which will also be returned as an "errorlevel", will
ECHO either be the status of the requested key lock (0=OFF, 1=ON) or
ECHO a combination of the three (C=64, N=32, S=16).
ECHO This batch file uses DEBUG to read the keyboard status.
ECHO Written by Rob van der Woude
page last uploaded: 2021-01-27, 16:12