Microsoft KB Archive/100496

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 13:57, 20 July 2020 by X010 (talk | contribs) (Text replacement - "<" to "<")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Microsoft Knowledge Base

How to Determine the State of the CAPS LOCK or NUM LOCK Keys

Last reviewed: October 19, 1994
Article ID: Q100496

The information in this article applies to:

  • Microsoft Test for Windows versions 1.0 and 2.0

SUMMARY

Microsoft Test does not include an intrinsic routine to allow you to check the state of the CAPS LOCK or NUM LOCK keys. However, you can call the Windows API GetKeyState() to check the status of any key on the keyboard, including the CAPS LOCK and NUM LOCK keys.

MORE INFORMATION

The GetKeyState() API call takes a single argument, the virtual key code of the desired key. It returns a zero (0) if the key is up or a non-zero value if the key is down.

For more information on GetKeyState(), see the "Windows SDK Reference" help file provided with Microsoft Test version 2.0 or the "Microsoft Windows Programmer's Reference" manual provided with the Microsoft Windows Software Development Kit (SDK).

Virtual key codes can be found in the WINUSER.INC file for Microsoft Test version 1.0 or the WINDOWS.INC file for Microsoft Test version 2.0.

The following example shows how to call the GetKeyState() Windows API from Microsoft Test:

' Must include the appropriate Windows API include file for
' Microsoft Test 1.0.  DECLARES.INC in Microsoft Test version 2.0
' contains all the Windows API declarations.

'$IFDEF _TEST20
  '$include 'declares.inc'
'$ELSE
  '$define TESTEVNT
  '$include 'mstest.inc'
  '$include 'winuser.inc'
'$ENDIF

' Make sure CAPS LOCK is off.

If GetKeyState(VK_CAPITAL) <> 0 Then

   QueKeys "{CAPSLOCK}"
   QueFlush False

End If


Additional reference words: 2.00 1.00

KBCategory: kbtool kbprg
KBSubcategory:


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 19, 1994
©1997 Microsoft Corporation. All rights reserved. Legal Notices.