This function posts a keyboard message to the specified window.
BOOL PostKeybdMessage( HWND hwnd, UINT VKey, KEY_STATE_FLAGS KeyStateFlags, UINT cCharacters, UINT* pShiftStateBuffer, UINT* pCharacterBuffer );
[in] Handle to the window that receives the message. It must identify a window owned by the calling thread. If hwnd is NULL, then the keyboard message is sent to the active window or window with the focus of the calling thread. If hwnd is –1, then the keyboard message is sent to the active window or window with the focus of the system foreground thread.
[in] Virtual key code. This parameter can be set to 0.
[in] State of the key. The key states are described in the following table.
Key is toggled.
Key was previously down.
Key is currently down.
Left or right CTRL key is down.
Left or right SHIFT key is down.
Left or right ALT key is down.
VK_CAPITAL is toggled.
Left CTRL key is down.
Left SHIFT key is down.
Left ALT key is down.
Left Windows logo key is down.
Right CTRL key is down.
Right SHIFT key is down.
Right ALT key is down.
Right Windows logo key is down
Corresponding character is dead character.
No characters in pCharacterBuffer to translate.
[in] Number of characters in the pCharacterBuffer array.
[in] Pointer to a buffer that contains a corresponding shift state entry for each character in the pCharacterBuffer array. The shift state for each character must be the same as the KeyStateFlags parameter. This parameter cannot be NULL.
[in] Pointer to a buffer that contains the characters to send. This parameter cannot be NULL.
Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.
The characters in pCharacterBuffer are the characters posted to the receiver's queue when TranslateMessage is called for the VK key event. Unlike the keybd_event function, PostKeybdMessage does not affect the global key state.
PostKeybdMessage does not support a different state for each translated character. If a different state is required for each character, then individual calls to PostKeybdMessage must be made.
If VKey is set to 0 when TranslateMessage is called, then the virtual key translation is also set to 0. Because 0 is not valid for virtual key, an application should ignore it.