This example turns on Caps Lock.

#define INCL_WININPUT
#include <OS2.H>
BYTE KeyState[256]; /* This is a 256 byte table   */
                    /* indexed by virtual key     */
                    /* value.                     */
                    /* For any virtual key, the   */
                    /* 0x80 bit is set if the key */
                    /* is down, and zero if it is */
                    /* up.  The 0x01 bit is set   */
                    /* if the key is toggled,     */
                    /* (pressed an odd number     */
                    /* of times), otherwise it is */
                    /* zero.                      */
WinSetKeyboardStateTable(HWND_DESKTOP,
                         KeyState,
                         FALSE); /* get a copy of the keyboard */
                                 /* state.                     */
KeyState[VK_CAPSLOCK] |= 0x01;   /* set the CAPSLOCK key to    */
                                 /* on state           */
WinSetKeyboardStateTable(HWND_DESKTOP,
                         KeyState,
                         TRUE); /* set the keyboard state */


[Back] [Next]