Best way to solve global hotkey handling in C #?

Possible duplicate:
How to register a global hotkey to say CTRL + SHIFT + (LETTER) using WPF and .NET 3.5?

I would like to have several global hotkeys in my new application (to control the application from anywhere in the windows), and all of these data sources / solutions that I found on the Internet seem to provide a peculiar solution for lameness (or solutions for only one g .hotkey, or solutions that create annoying mouse delays on the screen during operation).

Does anyone know of a resource that can help me achieve this, what can I learn? Anything?

Thank!:)

+24
c # global hotkeys
Sep 17 '08 at 8:32
source share
3 answers

The most enjoyable solution I 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); 

Notice how you can set different lambda for different hotkeys

+39
Apr 10 2018-10-10T00: 00Z
source share
— -
+7
Sep 17 '08 at 9:08
source share

I would handle this using P / Invoke to call RegisterHotKey () for each hotkey, and then use NativeForm (assuming you use WinForms) to get notified of the WM_HOTKEY message. This should contain most of your hotkey code in one place.

+5
Oct 11 '08 at 0:01
source share



All Articles