From b78c6972728454cde6f25f7df926223f547b1320 Mon Sep 17 00:00:00 2001 From: ybhgl Date: Fri, 13 Nov 2026 20:11:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=AF=8F=E6=AC=A1=E5=88=B7=E6=96=B0=20s?= =?UTF-8?q?hell=20=E6=B5=8F=E8=A7=88=E5=99=A8=E5=88=97=E8=A1=A8=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A6=96=E6=AC=A1=E5=8F=B3=E9=94=AE=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `GetIShellBrowserRecursive` 原先用 `static` 缓存 `GetIShellBrowsers()`, 只在 DFS 完全失败时重扫。资源管理器窗口开关、HWND 回收复用会让缓存匹配到 错误窗口,首次右键读到桌面/上一个位置。改为每次调用新鲜枚举。 --- src/shell/script/binding_types_com.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/shell/script/binding_types_com.cc b/src/shell/script/binding_types_com.cc index a7244b63..7a83d861 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;