悬浮条:本工具自身窗口不再算遮挡

在设置页里测试时,设置窗口正盖着锚定窗口,运行时判断因此一直隐藏悬浮条,
表现为“按钮不显示”。现在运行时的可见性判断与设置页检测一致:只把其他程序
的窗口当作遮挡,本工具窗口(主界面/设置窗口/覆盖层)一律忽略。

验证(独立宿主 + 真实窗口):
- 目标无遮挡 → 悬浮条显示(112x40,1 个按钮,逐像素透明)
- 本工具窗口完全盖住目标 → 悬浮条仍显示(修复前隐藏)
- 外部进程窗口盖住目标 → 隐藏,并在检测结果里点名该窗口

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
zimoyin
2026-10-13 14:51:41 +08:00
parent 4f53047429
commit 0b2f84860e
3 changed files with 13 additions and 25 deletions
+1 -1
View File
@@ -397,7 +397,7 @@ i3/o1
点击“检测显示条件”,按提示处理:
> 检测是在设置页里做的,而设置窗口本身会盖住目标窗口。因此**检测会忽略本工具自己的窗口**(主界面、设置窗口),只报告外部程序的遮挡;运行时仍然会严格判断——设置窗口关掉后,悬浮条才会按条件出现。
> 本工具自己的窗口(主界面、设置窗口)**不算遮挡**,无论是设置页的检测还是运行时判断:你在设置窗口里配置时,悬浮条照样会按条件显示。只有**别的程序**挡住了锚定窗口,悬浮条才会隐藏,并在检测结果里点名是哪个窗口挡住的。
1. 悬浮条是否启用;
2. 是否有至少一个启用按钮;
+11 -21
View File
@@ -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();
}
/// <summary>Run on a worker thread. Never activates windows, invokes buttons or runs commands.</summary>
/// <summary>
/// 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.
/// </summary>
public static FloatingBarDisplayCheck CheckDisplayConditions(FloatingBarDefinition bar)
{
return CheckDisplayConditions(bar, false);
}
/// <param name="ignoreOwnProcessWindows">
/// 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.
/// </param>
public static FloatingBarDisplayCheck CheckDisplayConditions(FloatingBarDefinition bar,
bool ignoreOwnProcessWindows)
{
IList<NativeWindowInfo> windows = null;
return EvaluateDisplay(bar, ref windows, ignoreOwnProcessWindows);
return EvaluateDisplay(bar, ref windows);
}
private static FloatingBarDisplayCheck EvaluateDisplay(FloatingBarDefinition bar,
ref IList<NativeWindowInfo> windows)
{
return EvaluateDisplay(bar, ref windows, false);
}
private static FloatingBarDisplayCheck EvaluateDisplay(FloatingBarDefinition bar,
ref IList<NativeWindowInfo> 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;
+1 -3
View File
@@ -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<FloatingBarDisplayCheck> check = Task.Run(
() => FloatingBarManager.CheckDisplayConditions(snapshot, true));
() => FloatingBarManager.CheckDisplayConditions(snapshot));
if (await Task.WhenAny(check, Task.Delay(10000)) != check)
{
if (!IsDisposed && !Disposing && version == _barEditVersion)