From aa5ca76b180b94680ee4f1f677581eb35bbf7424 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Mon, 20 Dec 2021 03:34:41 -0500 Subject: [PATCH] Check window is InternetExplorer type --- Flow.Launcher/ViewModel/MainViewModel.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index b525ac342..412af09fd 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -731,13 +731,19 @@ namespace Flow.Launcher.ViewModel ShellWindows shellWindows = new SHDocVw.ShellWindows(); // loop through all windows - foreach (SHDocVw.InternetExplorer window in shellWindows) + foreach (var window in shellWindows) { + if (window is not SHDocVw.InternetExplorer) + { + continue; + } + + var explorerWindow = (SHDocVw.InternetExplorer)window; // match active window - if (window.HWND == (int)handle) + if (explorerWindow.HWND == (int)handle) { // Required ref: Shell32 - C:\Windows\system32\Shell32.dll - var shellWindow = window.Document as Shell32.IShellFolderViewDual2; + var shellWindow = explorerWindow.Document as Shell32.IShellFolderViewDual2; // will be null if you are in Internet Explorer for example if (shellWindow != null)