diff --git a/Flow.Launcher.Infrastructure/Win32Helper.cs b/Flow.Launcher.Infrastructure/Win32Helper.cs index 54604a27118..6be0243899a 100644 --- a/Flow.Launcher.Infrastructure/Win32Helper.cs +++ b/Flow.Launcher.Infrastructure/Win32Helper.cs @@ -376,7 +376,8 @@ public static unsafe void SwitchToEnglishKeyboardLayout(bool backupPrevious) if (!IsForegroundWindow(hwnd)) { var result = PInvoke.SetForegroundWindow(hwnd); - if (!result) throw new Win32Exception(Marshal.GetLastWin32Error()); + // If we cannot set the foreground window, we can use the foreground window and switch the layout + if (!result) hwnd = PInvoke.GetForegroundWindow(); } // Get the current foreground window thread ID