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:
SUMMARYMicrosoft 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 INFORMATIONThe 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
©1997 Microsoft Corporation. All rights reserved. Legal Notices. |