From 0b2f84860efdce18269f1730728f378260f6d948 Mon Sep 17 00:00:00 2001 From: zimoyin <2556608754@qq.com> Date: Tue, 13 Oct 2026 14:51:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=82=AC=E6=B5=AE=E6=9D=A1=EF=BC=9A=E6=9C=AC?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E8=87=AA=E8=BA=AB=E7=AA=97=E5=8F=A3=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E7=AE=97=E9=81=AE=E6=8C=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在设置页里测试时,设置窗口正盖着锚定窗口,运行时判断因此一直隐藏悬浮条, 表现为“按钮不显示”。现在运行时的可见性判断与设置页检测一致:只把其他程序 的窗口当作遮挡,本工具窗口(主界面/设置窗口/覆盖层)一律忽略。 验证(独立宿主 + 真实窗口): - 目标无遮挡 → 悬浮条显示(112x40,1 个按钮,逐像素透明) - 本工具窗口完全盖住目标 → 悬浮条仍显示(修复前隐藏) - 外部进程窗口盖住目标 → 隐藏,并在检测结果里点名该窗口 Co-Authored-By: Claude Code --- docs/XPath定位.md | 2 +- .../Services/FloatingBarManager.cs | 32 +++++++------------ src/pacs_win_uia/UI/SettingsForm.cs | 4 +-- 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/docs/XPath定位.md b/docs/XPath定位.md index 6f7bdf3..4b5e775 100644 --- a/docs/XPath定位.md +++ b/docs/XPath定位.md @@ -397,7 +397,7 @@ i3/o1 点击“检测显示条件”,按提示处理: -> 检测是在设置页里做的,而设置窗口本身会盖住目标窗口。因此**检测会忽略本工具自己的窗口**(主界面、设置窗口),只报告外部程序的遮挡;运行时仍然会严格判断——设置窗口关掉后,悬浮条才会按条件出现。 +> 本工具自己的窗口(主界面、设置窗口)**不算遮挡**,无论是设置页的检测还是运行时判断:你在设置窗口里配置时,悬浮条照样会按条件显示。只有**别的程序**挡住了锚定窗口,悬浮条才会隐藏,并在检测结果里点名是哪个窗口挡住的。 1. 悬浮条是否启用; 2. 是否有至少一个启用按钮; diff --git a/src/pacs_win_uia/Services/FloatingBarManager.cs b/src/pacs_win_uia/Services/FloatingBarManager.cs index 9404fa3..01cf9af 100644 --- a/src/pacs_win_uia/Services/FloatingBarManager.cs +++ b/src/pacs_win_uia/Services/FloatingBarManager.cs @@ -392,7 +392,7 @@ namespace pacs_win_uia.Services var anchor = new Rectangle(rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top); string reason; if (runtime.Definition.RequireWindowVisible && - !WindowVisibility.IsVisibleOnScreen(runtime.Anchor, anchor, _ownProcessId, out reason)) + !WindowVisibility.IsVisibleOnScreen(runtime.Anchor, anchor, _ownProcessId, true, out reason)) { Hide(runtime); return; @@ -420,32 +420,22 @@ namespace pacs_win_uia.Services return results.ToArray(); } - /// Run on a worker thread. Never activates windows, invokes buttons or runs commands. + /// + /// Run on a worker thread. Never activates windows, invokes buttons or runs commands. + /// + /// The tool's own windows (main window, settings dialog) never count as occluders here, in the + /// runtime check as well as in the settings diagnostic: the operator's own UI is under their + /// control, and "the target is behind our own window" must not make the bar silently vanish. + /// Only other applications hide it. + /// public static FloatingBarDisplayCheck CheckDisplayConditions(FloatingBarDefinition bar) - { - return CheckDisplayConditions(bar, false); - } - - /// - /// True for the settings-page diagnostic: the tool's own windows (main window, this settings - /// dialog) are not counted as occluders. While the dialog is open it covers the target, so a - /// strict check would always report "被遮挡" and tell the operator nothing. Runtime keeps false. - /// - public static FloatingBarDisplayCheck CheckDisplayConditions(FloatingBarDefinition bar, - bool ignoreOwnProcessWindows) { IList windows = null; - return EvaluateDisplay(bar, ref windows, ignoreOwnProcessWindows); + return EvaluateDisplay(bar, ref windows); } private static FloatingBarDisplayCheck EvaluateDisplay(FloatingBarDefinition bar, ref IList windows) - { - return EvaluateDisplay(bar, ref windows, false); - } - - private static FloatingBarDisplayCheck EvaluateDisplay(FloatingBarDefinition bar, - ref IList windows, bool ignoreOwnProcessWindows) { var result = new FloatingBarDisplayCheck(); try @@ -490,7 +480,7 @@ namespace pacs_win_uia.Services result.Details = "锚定窗口:" + window + ";PID=" + window.ProcessId; if (bar.RequireWindowVisible && !WindowVisibility.IsVisibleOnScreen(window.Handle, window.WindowRectangle, System.Diagnostics.Process.GetCurrentProcess().Id, - ignoreOwnProcessWindows, out error)) + true, out error)) { result.Reason = "锚定窗口可见性不满足:" + error; return result; diff --git a/src/pacs_win_uia/UI/SettingsForm.cs b/src/pacs_win_uia/UI/SettingsForm.cs index 877f8d6..9b7015f 100644 --- a/src/pacs_win_uia/UI/SettingsForm.cs +++ b/src/pacs_win_uia/UI/SettingsForm.cs @@ -898,10 +898,8 @@ namespace pacs_win_uia.UI _barCheckStatus.Text = "正在后台检测当前草稿(只读,不执行操作)…"; try { - // Diagnostic on purpose: this dialog covers the target window, so "本工具窗口遮挡" must - // not make every check fail. Runtime still counts them. Task check = Task.Run( - () => FloatingBarManager.CheckDisplayConditions(snapshot, true)); + () => FloatingBarManager.CheckDisplayConditions(snapshot)); if (await Task.WhenAny(check, Task.Delay(10000)) != check) { if (!IsDisposed && !Disposing && version == _barEditVersion)