[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 708
  • Last Modified:

Keyboard Event Handling

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
jwnrb
Asked:
jwnrb
  • 5
  • 4
1 Solution
 
rogaut1Commented:
Hi,

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



Hope this helps !



Robert
0
 
rogaut1Commented:
0
 
rogaut1Commented:
0
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!

 
jwnrbAuthor Commented:
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
 
jwnrbAuthor Commented:
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
 
rogaut1Commented:
No, the KeyDown event works only when your form has the focus.
0
 
jwnrbAuthor Commented:
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
 
jwnrbAuthor Commented:
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
 
jwnrbAuthor Commented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now