Solved

How to detect key strokes in c# when my application is not active?

Posted on 2009-05-08
4
909 Views
Last Modified: 2013-12-17

I'm working on a custom clipboard manager. I pretty much want an app that replaces the windows clipboard with one that can store multiple instances of text, images, and/or files. The general idea is this will be a windows C# application (probably written with Visual C# 2008 Express Edition) where it will namely reside in the system tray and have no active window. I want to be able to use a specific key combination to pull up the active window for this application I'm creating. I don't want to bother with moving the mouse around or all that.

I guess it boils down to needing to be able to check all keystrokes against the specific combination setup for my application regardless what window is acting.

I've found some articles that discuss this in a broad manner but I'm really trying to get some code for this. Any help you can provide would be greatly appreciated. Thanks!
0
Comment
Question by:baijajusav
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 8

Assisted Solution

by:mac-will
mac-will earned 400 total points
ID: 24338830
0
 
LVL 3

Author Comment

by:baijajusav
ID: 24338901

That's probably exactly what I need. I'll test over the weekend to verify.
0
 
LVL 3

Accepted Solution

by:
baijajusav earned 0 total points
ID: 24339187
0
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 100 total points
ID: 24339252
Right...you basically only have three options:  (all involving external WinAPIs)
(1) Trap ALL keystrokes with a low level keyboard via WH_KEYBOARD_LL.
(2) POLL the keyboard with a Timer and the GetAsyncKeyState() API.
(3) Register your desired key combo as a system wide hotkey via RegisterHotkey().  This is the least resource intensive BUT only one process can register a unique key combo.  If another app has already taken your combo then you have no recourse but to pick another one or use methods #1 or #2 instead.
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

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 …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

734 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