I am building an add-on application in Visual C++ 6.0. How can you send a key combination (such as Control+K) to another application to invoke a menu shortcut (for example, control+o for open in a file menu)? I can do this in VB using SendKeys, and I wondered how it can be done in VC++.
Under Win32, you can use the keybd_event API to send keystrokes to another application. This function is called by the keyboard driver’s interrupt handler when a keystroke is detected so applications will not know the difference between a call to keybd_event and an actual key press.
If you are using NT 4 SP3 or later, you may want to use the newer SendInput function. Please refer to the API reference for additional details.