I have a c# winforms app that can be active or minimized. I want to be able to capture and override any existing shortcut so that NO matter what my app will respond to "Alt+D".
If the app has focus I can do this with
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys.Alt | Keys.D))
{
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
But when the app doesnt have focus it doesnt execute, e.g. if I am inside firefox my Ctrl D keystroke sequence doesnt get activated
How can I get this to work?
Ideally I want to be able to highlight with the mouse / select some text in ANY app and press Alt D and then send this text to my app.
update
http://www.fluxbytes.com/csharp/how-to-register-a-global-hotkey-for-your-application-in-c/
This worked for me perfectly