File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Flow.Launcher.Infrastructure Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -386,8 +386,12 @@ public static unsafe void SwitchToEnglishKeyboardLayout(bool backupPrevious)
386
386
// No installed English layout found
387
387
if ( enHKL == HKL . Null ) return ;
388
388
389
- // Get the current window thread ID
390
- var threadId = PInvoke . GetWindowThreadProcessId ( PInvoke . GetForegroundWindow ( ) ) ;
389
+ // Get the current foreground window
390
+ var hwnd = PInvoke . GetForegroundWindow ( ) ;
391
+ if ( hwnd == HWND . Null ) return ;
392
+
393
+ // Get the current foreground window thread ID
394
+ var threadId = PInvoke . GetWindowThreadProcessId ( hwnd ) ;
391
395
if ( threadId == 0 ) throw new Win32Exception ( Marshal . GetLastWin32Error ( ) ) ;
392
396
393
397
// If the current layout has an IME mode, disable it without switching to another layout.
You can’t perform that action at this time.
0 commit comments