Numlock help

 BBS: Inland Empire Archive
Date: 06-12-92 (21:33)             Number: 196
From: MIKE KELLY                   Refer#: NONE
  To: MIKE MELAMED                  Recvd: NO  
Subj: Numlock help                   Conf: (2) Quik_Bas
In a message of <Jun 05 18:00>, Mike Melamed (1:157/555) writes:
 >Is there a way to detect NumLock or CapsLock or Scroll Lock?
 >                  ^^^^^^

Here is how to do that and a little more if you like interrupts.

'$INCLUDE: 'qb.bi'
' Standard $INCLUDE  (Start QuickBASIC with "/L" command line option)
CLS                                            ' Clear Screen
DO                                             ' Start Loop
  DIM reg AS RegType                           ' Standard DIM
  reg.ax = &H200                               ' AH = 02H
  INTERRUPT &H16, reg, reg                     ' Int 16H
  RShift% = reg.ax AND 1                       ' Bit 0 of AL
  LShift% = (reg.ax \ 2) AND 1                 ' Bit 1 of AL
  Contrl% = (reg.ax \ 4) AND 1                 ' Bit 2 of AL
  AltKey% = (reg.ax \ 8) AND 1                 ' Bit 3 of AL
  Scroll% = (reg.ax \ 16) AND 1                ' Bit 4 of AL
  NumbLk% = (reg.ax \ 32) AND 1                ' Bit 5 of AL
  CapsLk% = (reg.ax \ 64) AND 1                ' Bit 6 of AL
  Insert% = (reg.ax \ 128) AND 1               ' Bit 7 of AL
  k$ = INKEY$                                  ' Check for key stroke
  IF k$ = CHR$(27) THEN quit% = -1             ' If Escape pressed then end
  COLOR 0, 7                                   ' Black on white
  Line25$ = SPACE$(80)                         ' Blank line
  ' Put some information in the line
  IF AltKey% THEN MID$(Line25$, 2, 4) = "Alt"
  IF Contrl% THEN MID$(Line25$, 8, 5) = "Ctrl"
  IF RShift% THEN MID$(Line25$, 15, 6) = "RShift"
  IF LShift% THEN MID$(Line25$, 24, 6) = "LShift"
  IF NumbLk% THEN MID$(Line25$, 34, 8) = "Num Lock"
  IF CapsLk% THEN MID$(Line25$, 46, 9) = "Caps Lock"
  IF Insert% THEN MID$(Line25$, 59, 6) = "Insert"
  IF Scroll% THEN MID$(Line25$, 69, 11) = "Scroll Lock"
  LOCATE 25, 1                                 ' Go to bottom of the screen
  PRINT Line25$;                               ' Print the line
LOOP UNTIL quit%                               ' End Loop
COLOR 7, 0                                     ' White on black
CLS                                            ' Clear screen


--- QM v1.00
 * Origin: Russian House, Portland, OR, USA (1:105/23.48)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET