Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Home » Tip Bank » C++
Language: C++
Expertise: Beginner
Dec 4, 1998

Simulating Keystrokes

Question:
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++.

Answer:
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.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date