Solved

Keyboard Event Handling

Posted on 2003-12-03
9
702 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
  • 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 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