Solved

Keyboard Event Handling

Posted on 2003-12-03
9
698 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
Comment Utility
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
Comment Utility
0
 
LVL 2

Accepted Solution

by:
rogaut1 earned 250 total points
Comment Utility
0
 

Author Comment

by:jwnrb
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:jwnrb
Comment Utility
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
Comment Utility
No, the KeyDown event works only when your form has the focus.
0
 

Author Comment

by:jwnrb
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

744 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now