0

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/

Nathan Smith
  • 8,271
  • 3
  • 27
  • 44
  • 2
    "implementing the keyboard hook" that's your problem. Use `RegisterHotkey` instead of abusing keyboard hooks. There is a number of duplicates: http://stackoverflow.com/search?q=user%3A445517+registerhotkey&submit=search – CodesInChaos Apr 16 '12 at 17:49
  • @CodeInChaos just implemented the RegisterHotkey method into my application a much cleaner method, going to update my question with your suggestion. Thanks – Nathan Smith Jun 18 '12 at 16:59

1 Answers1

2

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.

M.Babcock
  • 18,753
  • 6
  • 54
  • 84
  • Fixes the immediate problem, but still clearly the wrong solution. – CodesInChaos Apr 16 '12 at 17:52
  • @CodeInChaos - Of course, but I answered the question asked. The question is very direct. I was actually writing a comment to support your suggestion of using `RegisterHotkey`. I guess that isn't necessary now. – M.Babcock Apr 16 '12 at 17:55