diff --git a/src/shell/script/binding_types_com.cc b/src/shell/script/binding_types_com.cc index a7244b6..7a83d86 100644 --- a/src/shell/script/binding_types_com.cc +++ b/src/shell/script/binding_types_com.cc @@ -125,7 +125,10 @@ CComPtr GetIShellBrowserRecursive(HWND hWnd) { std::unordered_set recorded_hwnds; - static auto browsers = GetIShellBrowsers(); + // Enumerate fresh each call: a static cache goes stale as explorer windows + // open/close and HWNDs are recycled, which made the first right-click in a + // new window resolve to the desktop or a previous location. + auto browsers = GetIShellBrowsers(); auto GetIShellBrowser = [&](HWND hwnd) -> CComPtr { for (auto &[h, b] : browsers) { CComPtr psv;