Article ID: 127190 - Last Review: July 11, 2005 - Revision: 1.3 HOWTO: Toggle the NUM LOCK, CAPS LOCK, and SCROLL LOCK KeysThis article was previously published under Q127190 On This PageSUMMARY
The documentation for SetKeyboardState() correctly says that you cannot
use this API to toggle the NUM LOCK, CAPS LOCK, and SCROLL LOCK keys.
You can use keybd_event() to toggle the NUM LOCK, CAPS LOCK, and SCROLL LOCK keys under Windows NT. The same technique works for toggling CAPS LOCK and SCROLL LOCK under Windows 95, but it will not work for NUM LOCK. MORE INFORMATION
The following sample program turns the NUM LOCK light on if it is off. The
SetNumLock function defined here simulates pressing the NUM LOCK key, using
keybd_event() with a virtual key of VK_NUMLOCK. It takes a boolean value
that indicates whether the light should be turned off (FALSE) or on (TRUE).
The same technique can be used for the CAPS LOCK key (VK_CAPITAL) and the SCROLL LOCK key (VK_SCROLL). Sample Code
| Article Translations
|
Back to the top
