Ask Learn
Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
A version of this page is also available for
4/8/2010
This function synthesizes a keystroke. The system can use such a synthesized keystroke to generate a WM_KEYUP or WM_KEYDOWN message.
VOID keybd_event(
BYTE bVk,
BYTE bScan,
DWORD dwFlags,
DWORD dwExtraInfo
);
dwFlags
[in] Specifies various aspects of function operation. An application can use any combination of the following predefined constant values to set the flags.
Value | Description |
---|---|
KEYEVENTF_EXTENDEDKEY |
If specified, the scan code will be treated as an extended key by giving it a prefix byte having the value 0xE0 (224). |
KEYEVENTF_KEYUP |
If specified, the key is being released. If not specified, the key is being pressed. |
KEYEVENTF_SILENT |
If specified, a keystroke is simulated, but no clicking sound is made. |
None.
When keyboard input is disabled with EnableHardwareKeyboard(FALSE), you can simulate keyboard input using keybd_event.
Although keybd_event passes an OEM-dependent hardware scan code to the system, applications should not use the scan code. The system converts scan codes to virtual-key codes internally and clears the up/down bit in the scan code before passing it to applications.
The parameters bVk and bScan are treated independently. The OS does not use bVk to generate bScan and does not use bScan to generate bVk.
An application can simulate a press of the PRINTSCREEN key in order to obtain a screen snapshot and save it to the clipboard. To do this, call keybd_event with the bVk parameter set to VK_SNAPSHOT, and the bScan parameter set to 0 for a snapshot of the full screen or set bScan to 1 for a snapshot of the active window.
Header | winuser.h |
Library | Uibase.lib |
Windows Embedded CE | Windows CE 1.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |
EnableHardwareKeyboard
GetAsyncKeyState
GetKeyState
MapVirtualKey
PostKeybdMessage
Keyboard Functions
Please sign in to use this experience.
Sign in