views:

33

answers:

1

There is a small 3rd-party program in the notification area of the taskbar that uses Ctrl-F11 key combination to do a task. The problem is I am using the same shortcut but mine is shadowed by the other one. Basically, I can not do my thing when the user presses Ctrl-F11 even though my window is the one that is currently active. I thought the active window would have the priority in using key combinations, but apparently it is not the case. Considering the program is written in .NET C#, how can I get the shortcut precedence when my application is active?

A: 

If you cannot change the Key combination of the tray app and you must use the same in your app. An extreme approach could be to write a Windows Hook DLL in C++ or Delphi and filter all key presses for Ctrl-F11 and send a message to your app.

This is no small task, there are projects that hook the Windows Keyboard events on Code Project etc. You could adapt one of those. When you receive the keypress and your Window/Form is active you could use SendMessage to message your window.

This would be a last restort. It depends how badly you need it.

Nanook
Keyboard hooks are easy to do in C#, see http://blogs.msdn.com/toub/archive/2006/05/03/589423.aspx for a sample
Stuart Dunkeld