[英]Multiple global hotkeys in C# console application
要在C#的控制台應用程序中注冊全局熱鍵,我正在使用此處發布的代碼: https : //stackoverflow.com/a/3654821/3179989
它運行完美,但是當我添加多個熱鍵時,按一個熱鍵將導致運行所有hotkey_pressed事件:
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);
有人可以幫我更改代碼,還是建議我針對c#控制台中多個全局熱鍵的其他解決方案/想法。
提前致謝
這不適用於您正在使用的類。
僅注冊一個HotKeyPressed-Event。 在這種情況下,您可以使用簡單的if語句檢查HotKeyEventArgs
,以確定按下了哪些熱鍵。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.