0
votes

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/

1
"implementing the keyboard hook" that's your problem. Use RegisterHotkey instead of abusing keyboard hooks. There is a number of duplicates: stackoverflow.com/…CodesInChaos
@CodeInChaos just implemented the RegisterHotkey method into my application a much cleaner method, going to update my question with your suggestion. ThanksNathan Smith

1 Answers

2
votes

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.