void WINAPI keybd_event( BYTE bVk, BYTE bScan,
DWORD dwFlags, ULONG_PTR dwExtraInfo )
{
INPUT input;
input.type = INPUT_KEYBOARD;
input.u.ki.wVk = bVk;
input.u.ki.wScan = bScan;
input.u.ki.dwFlags = dwFlags;
input.u.ki.time = GetTickCount();
input.u.ki.dwExtraInfo = dwExtraInfo;
SendInput( 1, &input, sizeof(input) );
}
From: