// The callback invoked by the system for our registered key events. private IntPtr OnHotkeyPressed(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { // If this is not a hotkey event, or is not tagged as ours, ignore it. if (msg != 0x0312) { return(IntPtr.Zero); } int keyBindingID = wParam.ToInt32(); if (keyBindingID == F7Binding.ID) { F7Binding.Method(); handled = true; return(IntPtr.Zero); } foreach (KeyBinding keyBinding in KeyBindings) { if (keyBindingID == keyBinding.ID) { keyBinding.Method(); handled = true; break; } } return(IntPtr.Zero); }