private void OnMessageIntercepted(LowLevelMessage lowLevelMessage, ref bool handled) { LowLevelKeyboardMessage keyboardMessage = lowLevelMessage as LowLevelKeyboardMessage; if (handled || keyboardMessage == null) { return; } if (!IsTabKeyDown(keyboardMessage)) { return; } if (!IsKeyDown(_altKey)) { return; } bool shiftKeyDown = IsKeyDown(_shiftKey); bool ctrlKeyDown = IsKeyDown(_ctrlKey); AltTabHookEventArgs eventArgs = OnPressed(shiftKeyDown, ctrlKeyDown); handled = eventArgs.Handled; }
private AltTabHookEventArgs OnPressed(bool shiftDown, bool ctrlDown) { AltTabHookEventArgs altTabHookEventArgs = new AltTabHookEventArgs { ShiftDown = shiftDown, CtrlDown = ctrlDown }; AltTabHookEventHandler handler = Pressed; if (handler != null) { handler(this, altTabHookEventArgs); } return(altTabHookEventArgs); }
private void AltTabPressed(object sender, AltTabHookEventArgs e) { if (!Settings.Default.AltTabHook) { // Ignore Alt+Tab presses if the hook is not activated by the user return; } e.Handled = true; if (Visibility != Visibility.Visible) { tb.IsEnabled = true; _foregroundWindow = SystemWindow.ForegroundWindow; ActivateAndFocusMainWindow(); Keyboard.Focus(tb); if (e.ShiftDown) { LoadData(InitialFocus.PreviousItem); } else { LoadData(InitialFocus.NextItem); } if (Settings.Default.AutoSwitch && !e.CtrlDown) { _altTabAutoSwitch = true; tb.IsEnabled = false; tb.Text = "Press Alt + S to search"; } Opacity = 1; } else { if (e.ShiftDown) { PreviousItem(); } else { NextItem(); } } }