views:

91

answers:

4

my problem is very simple, but implementation can be hard!

I want that my application (Windows Application:: Visual C# .net) is launched whenever the user clicks some keys combinations (on his keyboard).

For example it types "Ctrl+W+W" and my application open, that's all, I want the simplest implementation, less code, memory...

Thanks :D

A: 

I don't think this is possible in the way that you framed this question. What is possible, however, is to have your application run automatically on startup without showing any forms, have it hook into Windows to monitor all keystrokes (I'm not sure how to do that part, exactly) and then show a form when the user presses a particular sequence of keys.

So in other words, your application would have to be running from the time Windows starts, but only show itself (make a form visible) when the user clicks a particular key sequence.

Update: here is a link to an article that discusses how to do global keystroke capture using C#: http://blogs.msdn.com/toub/archive/2006/05/03/589423.aspx.

MusiGenesis
here's the hardest part of the story, I want to know if Windows has a service that monitor "keystrokes" because running my application full time is a waste of memory especially users need it few times!
Omar Abid
You could write your own windows service to do this for you.
James
You can write your app so that it doesn't use much memory at all until you need to actually show a form (put everything but the core app in a separate DLL). Windows already has a ton of crap running all the time anyway.
MusiGenesis
@James: that's essentially what I'm proposing here. His app would be a windows service that pops up a form if the user enters certain keystrokes.
MusiGenesis
@both the windows service idea and the small program which will work like a server waiting for user input is good idea and I already have knowledge on windows services
Omar Abid
+1  A: 

You would need to write a keylogger type application in conjunction with your app which monitors for keyboard events. Once your specific shortcut is triggered you could then load your application.

See here for information on how to capture keystrokes.

James
I am curious to know the reason why someone down voted me for this answer it is what you need to do!
James
I wasn't suggesting actually creating a keylogger....the keyword was "keylogger TYPE application"
James
your suggestion is interesting, I +1 it... it may be the answer!
Omar Abid
+1  A: 

Create a shortcut to the application, and assign a hot-key combination to the shortcut. Depending on the O/S, not every keystroke combination can be assigned to a shortcut, e.g. you may be able to assign Ctrl+Alt+W but not Ctrl+W+W.

ChrisW
that solution! I remember I was using it for some ms-dos applications; while it works it seems to me that it's not robust and garantued
Omar Abid
+1  A: 

On Windows, you can create a shortcut (on the desktop) to your application.

When you open the properties of the shortcut. On the second tab (labeled shortcut), you can assign a shortcut key. But you can use only CTRL-ALT-key shortcuts.

GvS