简体   繁体   English

全球热键 - C#

[英]Global Hotkeys - C#

I have built an application which listens for a global hot key (Alt + Space currently), when I press the hot key when Google Chrome is in focus it brings my app to focus but also opens Chrome's context menu (right click menu). 我已经构建了一个应用程序来监听全局热键(当前为Alt + Space),当我按下热键时谷歌Chrome处于焦点时它会使我的应用程序聚焦,但也会打开Chrome的上下文菜单(右键菜单)。 I used the following dll for implementing the keyboard hook . 我使用以下dll来实现键盘钩子

Can I prevent this from happening? 我可以防止这种情况发生吗? If so how? 如果是这样的话? This isn't a major problem but if there is a way in which you can clear all existing hot keys tied to that combination then I'd like to learn this. 这不是一个主要问题,但如果有一种方法可以清除与该组合相关的所有现有热键,那么我想学习这个。

EDIT 编辑

The answer that I selected as being the correct one, is the correct one but for my problem. 我选择的答案是正确答案,但对我的问题是正确的。 To correctly implement this feature into a C# WinForm i used this tutorial which was very helpful: http://www.dreamincode.net/forums/topic/180436-global-hotkeys/ 要在C#WinForm中正确实现此功能,我使用本教程非常有帮助: http//www.dreamincode.net/forums/topic/180436-global-hotkeys/

The FAQ section of the linked article contains your answer: 链接文章的常见问题解答部分包含您的答案:

Question

I need to suppress some keystrokes after I have processed them. 我需要在处理它们之后抑制一些击键。

Answer 回答

Just set the e.Handled property to true in the key events you have processed. 只需在已处理的关键事件中将e.Handled属性设置为true It prevents the keystrokes being processed by other applications. 它可以防止其他应用程序处理击键。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM