Skip to content

Instantly share code, notes, and snippets.

@ObserverHerb
Created January 4, 2024 07:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ObserverHerb/8c63e8c49383d8d047340ed81d298cdd to your computer and use it in GitHub Desktop.
Save ObserverHerb/8c63e8c49383d8d047340ed81d298cdd to your computer and use it in GitHub Desktop.
Open On-Screen Keyboard Programmatically in Windows
#include <Windows.h>
int main()
{
INPUT input[3];
input[0].type = INPUT_KEYBOARD;
input[0].ki.wScan = 0;
input[0].ki.time = 0;
input[0].ki.dwExtraInfo = 0;
input[0].ki.wVk = 0x11;
input[0].ki.dwFlags = 0;
input[1].type = INPUT_KEYBOARD;
input[1].ki.wScan = 0;
input[1].ki.time = 0;
input[1].ki.dwExtraInfo = 0;
input[1].ki.wVk = 0x5B;
input[1].ki.dwFlags = 0;
input[2].type = INPUT_KEYBOARD;
input[2].ki.wScan = 0;
input[2].ki.time = 0;
input[2].ki.dwExtraInfo = 0;
input[2].ki.wVk = 0x4F;
input[2].ki.dwFlags = 0;
SendInput(3, input, sizeof(INPUT));
input[0].ki.dwFlags = KEYEVENTF_KEYUP;
input[1].ki.dwFlags = KEYEVENTF_KEYUP;
input[2].ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(3, input, sizeof(INPUT));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment