WinGetPhysKeyState: Difference between revisions
Appearance
Created page with "This function returns the physical key state. == Syntax == WinGetPhysKeyState(hwndDeskTop, sc); == Parameters == ;hwndDeskTop (HWND) - input :Desktop-window handle. :;HWN..." |
mNo edit summary |
||
Line 1: | Line 1: | ||
This function returns the physical key state. | This function returns the physical key state. | ||
== Syntax == | ==Syntax== | ||
WinGetPhysKeyState(hwndDeskTop, sc) | |||
== Parameters == | ==Parameters== | ||
;hwndDeskTop (HWND) - input | ;hwndDeskTop (HWND) - input:Desktop-window handle. | ||
:Desktop-window handle. | ::HWND_DESKTOP - The desktop-window handle | ||
: | ::Other - Specified desktop-window handle. | ||
The desktop-window handle | ;sc (LONG) - input:Hardware scan code. | ||
: | |||
;sc (LONG) - input | |||
:Hardware scan code. | |||
:Contains the scan code value in the low-order byte, and zero in the high-order byte. | :Contains the scan code value in the low-order byte, and zero in the high-order byte. | ||
== Returns == | ==Returns== | ||
;lKeyState (LONG) - returns | ;lKeyState (LONG) - returns:Key state. | ||
:Key state. | |||
:This value is the OR combination of the following bits: | :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== | ==Errors== | ||
Possible returns from WinGetLastError | Possible returns from WinGetLastError | ||
;PMERR_INVALID_HWND (0x1001) | ;PMERR_INVALID_HWND (0x1001):An invalid window handle was specified. | ||
:An invalid window handle was specified. | |||
== Remarks == | ==Remarks== | ||
This function returns information about the asynchronous (interrupt level) state of the virtual key indicated by the sc parameter. | 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). | This function returns the physical state of the key; it is not synchronized to the processing of input (see the WinGetKeyState function). | ||
== Example Code == | ==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. | 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. | ||
<pre> | <pre> | ||
Line 49: | Line 40: | ||
lKeyState = WinGetPhysKeyState(HWND_DESKTOP, lScancode); | lKeyState = WinGetPhysKeyState(HWND_DESKTOP, lScancode); | ||
/* Emit the high pitched beep if the caps lock is currently depressed; */ | /* Emit the high-pitched beep if the caps lock is currently depressed; */ | ||
/* otherwise, emit a low pitched beep */ | /* otherwise, emit a low-pitched beep */ | ||
if (lKeyState & 0x8000) | if (lKeyState & 0x8000) | ||
DosBeep(1000,100L); | DosBeep(1000,100L); | ||
else | else | ||
DosBeep(200,100L); | DosBeep(200,100L); | ||
</pre> | </pre> | ||
== Related Functions == | == Related Functions == | ||
* WinEnablePhysInput | * WinEnablePhysInput |
Latest revision as of 21:53, 12 April 2024
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