Skip to content

Instantly share code, notes, and snippets.

@brenttaylor
Created October 23, 2012 10:22
Show Gist options
  • Save brenttaylor/3938048 to your computer and use it in GitHub Desktop.
Save brenttaylor/3938048 to your computer and use it in GitHub Desktop.
void SendKey(int vk, BOOL bExtended, bool KeyUp) {
KEYBDINPUT Keyboard;
INPUT Input;
ZeroMemory(&Keyboard, sizeof(KEYBDINPUT));
ZeroMemory(&Input, sizeof(INPUT));
if (bExtended) {
Keyboard.dwFlags |= KEYEVENTF_EXTENDEDKEY;
}
if (KeyUp){
Keyboard.dwFlags |= KEYEVENTF_KEYUP;
}
Keyboard.wVk = vk;
Input.type = INPUT_KEYBOARD;
Input.ki = Keyboard;
SendInput(1, &Input, sizeof(Input));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment