private IntPtr HookCallback(int nCode, IntPtr wParam, ref KBDLLHOOKSTRUCT lParam) { if (nCode < 0) { return(CallNextHookEx(hookID, nCode, wParam, ref lParam)); } bool doAction = (wParam == (IntPtr)WM_KEYUP); bool done = false; action = QActionType.None; popupAction = frmGlobalInfoBox.ActionType.None; switch (lParam.vkCode) { case 160: case 161: controller.NotifyShift(); break; case VK_MEDIA_NEXT_TRACK: if (doAction) { action = QActionType.Next; popupAction = frmGlobalInfoBox.ActionType.Next; } done = true; break; case VK_MEDIA_PREV_TRACK: if (doAction) { action = QActionType.Previous; popupAction = frmGlobalInfoBox.ActionType.Previous; } done = true; break; case VK_MEDIA_STOP: if (doAction) { action = QActionType.Stop; popupAction = frmGlobalInfoBox.ActionType.Stop; } done = true; break; case VK_MEDIA_PLAY_PAUSE: if (doAction) { action = QActionType.PlayPause; popupAction = frmGlobalInfoBox.ActionType.PlayPause; } done = true; break; case VK_VOLUME_UP: if (doAction && controller.LocalVolumeControl && controller.Playing) { action = QActionType.VolumeUp; popupAction = frmGlobalInfoBox.ActionType.VolumeUp; done = true; } break; case VK_VOLUME_DOWN: if (doAction && controller.LocalVolumeControl && controller.Playing) { action = QActionType.VolumeDown; popupAction = frmGlobalInfoBox.ActionType.VolumeDown; done = true; } break; default: doAction = false; break; } if (action != QActionType.None) { controller.RequestAction(action); } if (popupAction != frmGlobalInfoBox.ActionType.None) { frmGlobalInfoBox.Show(controller, popupAction); } if (done) { return((IntPtr)1); } else { return(CallNextHookEx(hookID, nCode, wParam, ref lParam)); } }