Jump to content

WinGetPhysKeyState

From EDM2

This function returns the physical key state.

Syntax

WinGetPhysKeyState(hwndDeskTop, sc)

Parameters

hwndDeskTop (HWND) - input
Desktop-window handle.
HWND_DESKTOP - The desktop-window handle
Other - Specified desktop-window handle.
sc (LONG) - input
Hardware scan code.
Contains the scan code value in the low-order byte, and zero in the high-order byte.

Returns

lKeyState (LONG) - returns
Key state.
This value is the OR combination of the following bits:
0x0001: The key has been pressed since the last time this function was issued, or since the system has been started if this is the first time the call has been issued.
0x8000: The key is down.

Errors

Possible returns from WinGetLastError

PMERR_INVALID_HWND (0x1001)
An invalid window handle was specified.

Remarks

This function returns information about the asynchronous (interrupt level) state of the virtual key indicated by the sc parameter.

This function returns the physical state of the key; it is not synchronized to the processing of input (see the WinGetKeyState function).

Example Code

This example uses WinGetPhysKeyState to check the current state of the caps lock key; if it is depressed, a high pitch beep is emitted, while a low pitch beep is emitted if it is not depressed.

#define INCL_WININPUT     /* Window Input functions */
#define INCL_DOSPROCESS   /* OS/2 Process functions */
#include <os2.h>

LONG   lKeyState;         /* Key state              */
LONG   lScancode;         /* Scan code value        */

/* Get the physical key state for the caps lock key */
lScancode = 0x3a;
lKeyState = WinGetPhysKeyState(HWND_DESKTOP, lScancode);

/* Emit the high-pitched beep if the caps lock is currently depressed; */
/* otherwise, emit a low-pitched beep                                  */
if (lKeyState & 0x8000)
   DosBeep(1000,100L);
else
   DosBeep(200,100L);

Related Functions

  • WinEnablePhysInput
  • WinFocusChange
  • WinGetKeyState
  • WinQueryFocus
  • WinSetFocus
  • WinSetKeyboardStateTable