home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 24 / CDACTUAL24.iso / SHARE / os2 / edm2 / common / snippets / numlock4.txt < prev    next >
Encoding:
Internet Message Format  |  1997-01-25  |  1.8 KB

  1. From: rhasty@dialnet.net
  2.  
  3. #define INCL_WININPUT
  4. #define INCL_DOSPROCESS
  5. #include <OS2.H>
  6. #include <stdio.h>
  7. void main()
  8. {
  9.     BOOL rc;
  10.     BYTE KeyState[256]; /* This is a 256 byte table   */
  11.                         /* indexed by virtual key     */
  12.                         /* value.                     */
  13.                         /* For any virtual key, the   */
  14.                         /* 0x80 bit is set if the key */
  15.                         /* is down, and zero if it is */
  16.                         /* up.  The 0x01 bit is set   */
  17.                         /* if the key is toggled,     */
  18.                         /* (pressed an odd number     */
  19.                         /* of times), otherwise it is */
  20.                         /* zero.                      */
  21.     
  22.     DosSetPriority( PRTYS_PROCESS, PRTYC_IDLETIME, 2,0);
  23.     while(1)
  24.     {
  25.         rc=WinSetKeyboardStateTable(HWND_DESKTOP,
  26.           /* the address of the second element is passed so that the */
  27.           /* key number corresponds to the array index               */
  28.                                  &KeyState,
  29.                                  FALSE); /* get a copy of the keyboard */
  30.                                          /* state.                     */
  31.         if(rc==FALSE)
  32.         {
  33.             WinAlarm(HWND_DESKTOP, WA_ERROR);
  34.             return;
  35.         }
  36.         KeyState[VK_NUMLOCK] |= 0x01;    /* set the NUMLOCK key to     */
  37.                                          /* on state                   */
  38.         rc=WinSetKeyboardStateTable(HWND_DESKTOP,
  39.                                  &KeyState,
  40.                                  TRUE); /* set a copy of the keyboard */
  41.                                         /* state.                     */
  42.         DosSleep(5000);
  43.         if(rc==FALSE)
  44.             puts("Error Setting copy");
  45.     } // While 
  46. } // main 
  47.