Simulating key presses in your program with keybd_event function

By 42Gears Team
VOID keybd_event(BYTE bVk, BYTE bScan, DWORD dwFlags, DWORD dwExtraInfo);
void SendStringKeys(char* pszChars) { while (*pszChars != NULL) { if ( (*pszChars >= 'A') && (*pszChars <= 'Z') ) keybd_event(VK_SHIFT, 0, KEYEVENTF_SILENT, 0); keybd_event(toupper(*pszChars), 0, KEYEVENTF_SILENT, 0); keybd_event(toupper(*pszChars), 0, KEYEVENTF_KEYUP|KEYEVENTF_SILENT, 0); if ( (*pszChars >= 'A') && (*pszChars <= 'Z') ) keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP|KEYEVENTF_SILENT, 0); pszChars++; } }
And here is an example of how to call SendStringKeys function.
int _tmain(int argc, _TCHAR* argv[]) { SendStringKeys("Hello World."); return 0; }

“Written with expertise and passion to help you understand the topic better.”

4
42Gears Team – Content Author
Published on: October 11, 2009

Subscribe to our newsletter

Stay updated with the latest news, articles, and resources on enterprise mobility.

Weekly articles
Actionable insights delivered once a week. No noise.
No spam
Your privacy matters. Unsubscribe anytime.