From 2f69032eea71046d3994c5c7e2554147371c0cac Mon Sep 17 00:00:00 2001 From: dedonnodev <41230012+dedonnodev@users.noreply.github.com> Date: Wed, 29 Jul 2026 12:59:43 +0200 Subject: [PATCH] Fixed focus search box when Flow Launcher starts with Windows --- Flow.Launcher/MainWindow.xaml.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 4866c0deae6..2a57a1eb650 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -212,6 +212,22 @@ private void OnLoaded(object sender, RoutedEventArgs e) // Since the default main window visibility is visible, so we need set focus during startup QueryTextBox.Focus(); + // When the window is shown on startup, focusing QueryTextBox is not enough: the window also + // has to be activated to actually take OS-level keyboard focus. Otherwise, when Flow Launcher + // is auto-started with Windows (Startup folder or logon task), the search box looks focused but + // keystrokes go elsewhere until the user clicks it. + // This is dispatched at Loaded priority because Activate() throws if the window has not finished + // being shown yet, and skipped entirely when the window starts hidden for the same reason. + if (!_settings.HideOnStartup) + { + Dispatcher.BeginInvoke(new Action(() => + { + if (!_viewModel.MainWindowVisibilityStatus) return; + Activate(); + QueryTextBox.Focus(); + }), DispatcherPriority.Loaded); + } + // Set the initial state of the QueryTextBoxCursorMovedToEnd property // Without this part, when shown for the first time, switching the context menu does not move the cursor to the end. _viewModel.QueryTextCursorMovedToEnd = false;