Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to tackle global hotkey processing in c#? [duplicate]

Tags:

c#

global

hotkeys

Possible Duplicate:
How can I register a global hot key to say CTRL+SHIFT+(LETTER) using WPF and .NET 3.5?

I'd like to have multiple global hotkeys in my new app (to control the app from anywhere in windows), and all of the given sources/solutions I found on the web seem to provide with a sort of a limping solution (either solutions only for one g.hotkey, or solutions that while running create annoying mouse delays on the screen).

Does anyone here know of a resource that can help me achive this, that I can learn from? Anything?

Thanks ! :)


2 Answers

The nicest solution I've found is http://bloggablea.wordpress.com/2007/05/01/global-hotkeys-with-net/

Hotkey hk = new Hotkey();

hk.KeyCode = Keys.1;
hk.Windows = true;
hk.Pressed += delegate { Console.WriteLine("Windows+1 pressed!"); };

hk.Register(myForm); 

Note how you can set different lambdas to different hotkeys

like image 54
Ohad Schneider Avatar answered Sep 14 '25 12:09

Ohad Schneider


http://www.codeproject.com/KB/cs/CSLLKeyboardHook.aspx

If you're not using .net 3.5.

like image 24
arul Avatar answered Sep 14 '25 14:09

arul