Solved

Keyboard Event Handling

Posted on 2003-12-03
9
704 Views
Last Modified: 2010-04-16
Hi,
I like to develop a small test application in which while the program is running in the background, if a certain keyboard combination is detected a message box will popup.

Say for example, Control 5.  This needs to be done while the program is running but not neccessarily in focus. I can be in Iexplorer and i hit Control F5 and the message box pops up but the program shouldnt refocus.

any suggestions with the KeyUp/Down events i can find useful? I am in a bit of a pickle.

thanks
0
Comment
Question by:jwnrb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 2

Expert Comment

by:rogaut1
ID: 9868923
Hi,

   I think this is what you are looking for : http://www.developerfusion.com/show/271/



Hope this helps !



Robert
0
 
LVL 2

Expert Comment

by:rogaut1
ID: 9868940
0
 
LVL 2

Accepted Solution

by:
rogaut1 earned 250 total points
ID: 9868953
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:jwnrb
ID: 9869156
Hmm, it appears to work however when the prog is minimised the text box is also minimised on the tray. how can i force the messagebox.show event to pop up in the middle of the screen no matter whats open
0
 

Author Comment

by:jwnrb
ID: 9869308
Hmm, also, it seems this code is quite complicated. Anything else simpler?
Like this:

private void txtTest_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
            {
                  if(e.KeyCode == Keys.D5 && e.Modifiers == Keys.ControlKey) // Ctrl+5
                  {
                        MessageBox.Show("You pressed the special key combination.  Good for you!","Key Catcher",MessageBoxButtons.OK, MessageBoxIcon.Information);
                  }
            }

but works in the background and on the form itself (this code doesnt actually work yet but the jist of it)
0
 
LVL 2

Expert Comment

by:rogaut1
ID: 9869512
No, the KeyDown event works only when your form has the focus.
0
 

Author Comment

by:jwnrb
ID: 9869545
Oh, so the only other way is to use what you provided?  Okay, I cant seem to find in the src then where i can decided which key stroke combinations i want to invoke the event.
also how can i cause a messagebox to take over the screen (like being an obnoxious popup more or less)

0
 

Author Comment

by:jwnrb
ID: 9869932
Just realised where to change the hot key. my bad.
anyways, i cant figure out the message box so it popups over in the application whre it was called
0
 

Author Comment

by:jwnrb
ID: 9870120
Well my boss likes it thus far and wants me instead of the msgbox, wants text to be sent from the program to an application.

such that, if i am in Word, Excel, Notepad, etc, a predefined string of text would be sent to the program and typed out such, "hello" for example and the program can not lose focus.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question