Solved

Listen a key without a focus on our application

Posted on 2011-02-21
4
382 Views
Last Modified: 2012-05-11
Hi,

I've an application(C# 4.0-WPF), which is hidden and can be displayed by clicking on the systray icon or on an other frame I created(small frame which is docked left and topmost).

My customer wants to add a new way to display the application: When pressing on a "F" key(e.g. F9).

How can I do to know when I got this key stroke if my application hasn't the focus?

Thank you very much
0
Comment
Question by:Nargzul
  • 2
4 Comments
 
LVL 16

Expert Comment

by:sjklein42
ID: 34942344
To intercept hotkeys you need a background process.  There is a free (shareware) program that I use to do this on my systems.  You can do this without programming if you want to take this approach.

It is called "The Wonderful Icon".  This taskbar icon lets you define hotkeys to activate programs and do many other useful things.  I have used it for many years without any problems.

http://www.thewonderfulicon.com/download.html

As they say:


About The Wonderful Icon:

The Wonderful Icon 2.2 is a small Windows utility that resides in your PC's taskbar tray. Try it and you'll be hooked!

TWI has lots of wonderful features. With it, you can:

Assign hotkeys for common tasks such as minimize windows, restart Windows, etc.
Minimize programs onto the taskbar tray instead of just onto the taskbar, either by a keystroke or by right-clicking a window's Minimize button with your mouse
Configure a menu of easily-accessible commands
Increase or decrease speaker volume with the press of a button
Automatically run programs at start-up, and hide them, minimize them to the taskbar tray, etc.
Lots more!
Oh yeah, and it's free!

0
 
LVL 1

Author Comment

by:Nargzul
ID: 34942858
I can't do anything with that... I'm developing a c# application which is still running, I can't do this interacting with my software. And I need a code-c# solution sorry :/
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 34944374
You can either:
(1) Use the RegisterHotKey() API to register a specific hot-key combo and get notified when it gets pressed.
(2) Use a low level keyboard hook via WH_KEYBOARD_LL to listen to ALL keystrokes and intercept your specific combo.
0
 
LVL 1

Author Closing Comment

by:Nargzul
ID: 34977374
Thank you, but it's a pity that you didn't included a code ;)
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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…

803 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