1

To register global hotkey in console application in C#, I am using the code posted here: https://stackoverflow.com/a/3654821/3179989

It works perfectly, but when I add multiple hotkeys, pressing one hotkey will result in running all of the hotkey_pressed events:

   HotKeyManager.RegisterHotKey(Keys.E, KeyModifiers.Control);
   HotKeyManager.HotKeyPressed += new EventHandler<HotKeyEventArgs>(HotKeyManager_HotKeyPressed);

   HotKeyManager.RegisterHotKey(Keys.A, KeyModifiers.Control);
   HotKeyManager.HotKeyPressed += new EventHandler<HotKeyEventArgs>(HotKeyManager_HotKeyPressed2);

Can somebody help me to change the code, or suggest me any other solution/idea for multiple global hotkeys in c# console.

thanks in advance

4

1 回答 1

1

这不适用于您正在使用的课程。

只注册一个 HotKeyPressed-Event。在这种情况下,您可以HotKeyEventArgs使用一个简单的 if 语句来检查,以确定您按下了哪个热键。

于 2014-07-06T17:18:59.350 回答