Index of Functions ------------------ 1: KeyboardState Function Name ( 1): KeyboardState -------------------------------------------------------------------------------- 'Date Created: 03-Apr-2010 04:01:42 PM 'Last Updated: 03-Apr-2010 05:18:02 PM 'Created By : Ira J. Perlow 'Updated By : Ira J. Perlow FUNCTION KeyboardState AS C () 'DESCRIPTION: Returns a string of characters indicating the state of the virtual Keyboard & state keys 'LIMITATIONS:X '========================================================================= ' Created by Computer Systems Design & Associates ' Copyright 2010 Computer Systems Design & Associates, All Rights Reserved ' http://www.csda1.com ' You may use this code at your own risk in whole or as a part. ' ' Use in full or part in operational code is permitted with proper ' attributions to the source, and preserving the Copyrights and this section ' except it may not be sold as part of any software package that includes a ' library of functions as a primary use of the software package. ' ' Use in instructional materials is permitted if provided without modification as source '========================================================================= ' KeyboardState - Version 1.01 Release Date: 20100403 ' ' Syntax ' C KeyboardState() ' ' Purpose: Returns a string of characters indicating the state of the virtual Keyboard & state keys ' ' Input: None ' ' Output: Returns a string of characters indicating the state of the virtual Keyboard ' (e.g. Capslock, NumLock, Scrolllock) and whether certain shift-type keys are down. ' lowercase character indicates key is down, Uppercase character indicates state of keyboard ' c - CapsLock key is pressed down ' C - CapsLock state is on ' n - NumLock key is pressed down ' N - NumLock state is on ' s - ScrollLock key is pressed down ' S - ScrollLock state is on ' h - shift key is pressed down ' t - Ctrl key is pressed down ' a - Alt key is pressed down ' w - Left Windows key is pressed down ' x - Right Windows key is pressed down ' p - Applications key is pressed down ' ' Errors: None ' ' Examples: ' ?KeyboardState() ' Return state of CapsLock, NumLock and ScrollLock and Shift, Ctrl and Alt states ' ' Notes: '====================================================================== ' Declare API for Alpha declare user32 GetKeyStateA@GetKeyState LL ' Codes to return various Keyboard State values dim Shift as n Shift=16 ' 10h dim Ctrl as n Ctrl=17 ' 11h dim Alt as n Alt=18 ' 12h dim CapsLock as n CapsLock=20 ' 14h dim NumLock as n NumLock=144 ' 90h dim ScrollLock as n ScrollLock=145 ' 91h dim LeftWindows as n LeftWindows=91 ' 5Bh Left Windows key dim RightWindows as n RightWindows=92 ' 5Ch Right Windows key dim AppsWindow as n AppsWindow=93 ' 5Dh Applications key dim keyst as n dim KeyState as c KeyState="" ' Set characters in return string for each Keyst=GetKeyStateA(CapsLock) KeyState=KeyState+IF((keyst.and.32768)=0,"","c")+IF((keyst.and.1)=0,"","C") Keyst=GetKeyStateA(NumLock) KeyState=KeyState+IF((keyst.and.32768)=0,"","n")+IF((keyst.and.1)=0,"","N") Keyst=GetKeyStateA(ScrollLock) KeyState=KeyState+IF((keyst.and.32768)=0,"","s")+IF((keyst.and.1)=0,"","S") Keyst=GetKeyStateA(Shift) KeyState=KeyState+IF((keyst.and.32768)=0,"","h") Keyst=GetKeyStateA(Ctrl) KeyState=KeyState+IF((keyst.and.32768)=0,"","t") Keyst=GetKeyStateA(Alt) KeyState=KeyState+IF((keyst.and.32768)=0,"","a") Keyst=GetKeyStateA(LeftWindows) KeyState=KeyState+IF((keyst.and.32768)=0,"","w") Keyst=GetKeyStateA(RightWindows) KeyState=KeyState+IF((keyst.and.32768)=0,"","x") Keyst=GetKeyStateA(AppsWindow) KeyState=KeyState+IF((keyst.and.32768)=0,"","p") KeyboardState=Keystate 'ui_msg_box("Keyboard State","Keyboard State="+Keystate) EXIT FUNCTION END FUNCTION End Function ( 1)---------------------------------------------------------------