简体   繁体   中英

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). I used the following dll for implementing the keyboard hook .

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/

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. It prevents the keystrokes being processed by other applications.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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