I have C# app that monitors keystrokes via KeyDown and KeyPress events. Specifically, it watches for a VolumeMute keystroke (from a handheld device) to do some special processing. It works fine with one problem: Windows seems to intercept the VolumeMute keystroke and mutes the system volume (which I don't want to happen). I think Windows intercepts the keystroke before it is processed by my app because even when I signal the keystroke was handled (e.Handled = true), it mutes the system volume anyway. BTW, the same code works perfectly for other keystrokes I'm catching (ex Backspace, ect).
Is there a way to stop Windows from doing this volume mute?
System: WinXP SP3, .Net 4 Client Profile, Windows Forms app
Code snips
bool keyHandled = false;
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
if (keyHandled)
{
e.Handled = true;
}
}
// =====================================
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
keyHandled = false;
switch (e.KeyCode)
{
case Keys.VolumeMute:
DoSpecialProcessing();
keyHandled = true;
break;
default:
break;
}
e.Handled = keyHandled;
}