[英]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.