I'm trying to make my application to be always presented on desktop level. It means that my app need to ignore key sequences like LWin+D or RWin+D . I tried to make it work this way:
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (prefixSeen)
{
if (keyData == Keys.D)
{
MessageBox.Show("Got it!");
}
prefixSeen = false;
return true;
}
if (keyData == Keys.LWin)
{
prefixSeen = true;
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
But it catches only the the RWin/LWin buttons, without the D button.
I've also tried to create my own message filter, but I've got lost in it. All these messages and Bitwise:
public class KeystrokMessageFilter : System.Windows.Forms.IMessageFilter
{
public KeystrokMessageFilter() { }
public bool PreFilterMessage(ref Message m)
{
if ((m.Msg == 256 /*0x0100*/))
{
switch (((int)m.WParam) | ((int)Control.ModifierKeys))
{
case (int)(Keys.Control | Keys.Alt | Keys.K):
MessageBox.Show("You pressed ctrl + alt + k");
break;
case (int)(Keys.Control | Keys.C): MessageBox.Show("ctrl+c");
break;
case (int)(Keys.Control | Keys.V): MessageBox.Show("ctrl+v");
break;
case (int)Keys.Up: MessageBox.Show("You pressed up");
break;
}
}
return false;
}
}
Application.AddMessageFilter(keyStrokeMessageFilter);
So, how do I make my application to catch/ignore R/LWin+D?