File tree Expand file tree Collapse file tree 1 file changed +2
-13
lines changed
Flow.Launcher.Infrastructure Expand file tree Collapse file tree 1 file changed +2
-13
lines changed Original file line number Diff line number Diff line change @@ -365,21 +365,10 @@ public static unsafe void SwitchToEnglishKeyboardLayout(bool backupPrevious)
365
365
// No installed English layout found
366
366
if ( enHKL == HKL . Null ) return ;
367
367
368
- // When application is exiting, the Application.Current will be null
369
- if ( Application . Current == null ) return ;
370
-
371
- // Get the FL main window
372
- var hwnd = GetWindowHandle ( Application . Current . MainWindow , true ) ;
368
+ // Get the foreground window
369
+ var hwnd = PInvoke . GetForegroundWindow ( ) ;
373
370
if ( hwnd == HWND . Null ) return ;
374
371
375
- // Check if the FL main window is the current foreground window
376
- if ( ! IsForegroundWindow ( hwnd ) )
377
- {
378
- var result = PInvoke . SetForegroundWindow ( hwnd ) ;
379
- // If we cannot set the foreground window, we can use the foreground window and switch the layout
380
- if ( ! result ) hwnd = PInvoke . GetForegroundWindow ( ) ;
381
- }
382
-
383
372
// Get the current foreground window thread ID
384
373
var threadId = PInvoke . GetWindowThreadProcessId ( hwnd ) ;
385
374
if ( threadId == 0 ) throw new Win32Exception ( Marshal . GetLastWin32Error ( ) ) ;
You can’t perform that action at this time.
0 commit comments