Solved

Check for Keyboard Key

Posted on 2006-06-27
1
677 Views
Last Modified: 2012-05-05
I am trying to write a vb.net application that watches for a specific key. When the key is pressed it performs a specific action. The problem is that i want to watch for this key while the program does not have focus and the program is in the system tray.

I found some code that kind of allows me to do this, but it is for blocking the OS from receiving these keys. In order to block them the code uses some pretty advanced API's and the entire computer hangs for a few seconds while the program is receiving those keys. I modified the code to perform an anction instead of blocking the keys, but the program still hangs often.

Is there an easier way to perfrom an action when a key is pressed if i don't want to block the OS from receiving the keys?
0
Comment
Question by:Paul S
1 Comment
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 50 total points
ID: 16998362
Three basic methods:

(1) Register a Hotkey:
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21549775.html

(2) Use a low level keyboard hook:
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21584180.html

(3) Use a timer to poll the keyboard state:
I don't recommend this approach...
0

Featured Post

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!

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

730 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