Let’s talk the topic directly. keybd_event() can send key board events, which is available in WinCE 1.0 and later. The Win32 version of the function is also available in win9x/nt3.1, so it’s toooold. You can also use PostKeybdMessage available after WinCE 2.0.
keybd_event taks four parameters.
VOID keybd_event(
BYTE bVk,
BYTE bScan,
DWORD dwFlags,
DWORD dwExtraInfo
);bVk
- [in] Specifies a virtual-key code. The code must be a value in the range 1 to 254. For a list of virtual-key codes, see Virtual-Key Codes.
- bScan
- [in] Specifies a hardware scan code for the key.
- 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
DescriptionKEYEVENTF_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.- dwExtraInfo
- [in] Specifies an additional 32-bit value associated with the keystroke.
In most conditions, you may only need the first and third parameters.
Virtual-key code:
VK_0 thru VK_9 are the same as ASCII ’0′ thru ’9′ (0×30 – 0×39)
VK_A thru VK_Z are the same as ASCII ‘A’ thru ‘Z’ (0×41 – 0x5A)You can get others from MSDN
So, this is an simle example of send ‘F’ key press event:
const byte VK_F = 0×46;
keybd_event(VK_F, 0, 0, 0); // key pressed
keybd_event(VK_F, 0, KEYEVENTF_KEYUP, 0); // key released
see also: MSDN: keybd_event()












