From 06981dfff36041a506db5971dcd26417db75b7ea Mon Sep 17 00:00:00 2001 From: yu <191972707@qq.com> Date: Wed, 28 Oct 2026 15:43:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=82=B9=E5=87=BB=E5=89=8D=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E6=9C=80=E5=B0=8F=E5=8C=96/=E5=B1=8F=E5=B9=95?= =?UTF-8?q?=E5=A4=96=E7=AA=97=E5=8F=A3=E5=B9=B6=E8=87=AA=E5=8A=A8=E8=BF=98?= =?UTF-8?q?=E5=8E=9F=EF=BC=8C=E4=BF=AE=E5=A4=8D=20-32000=20=E5=9D=90?= =?UTF-8?q?=E6=A0=87=E7=82=B9=E5=87=BB=E8=90=BD=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/capabilities/desktop-uia.ts | 33 +++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/main/capabilities/desktop-uia.ts b/src/main/capabilities/desktop-uia.ts index ae04d13..89ffd74 100644 --- a/src/main/capabilities/desktop-uia.ts +++ b/src/main/capabilities/desktop-uia.ts @@ -167,7 +167,37 @@ try { } catch { $el = $null } if ($null -eq $el) { Write-Output "JSON_NOT_FOUND"; exit 0 } $rect = $el.Current.BoundingRectangle -$offscreen = $el.Current.IsOffscreen -or $rect.Width -le 0 -or $rect.Height -le 0 +Add-RpaUser32 +$vsX = [WinRpa.RpaUser32Click]::GetSystemMetrics(76) +$vsY = [WinRpa.RpaUser32Click]::GetSystemMetrics(77) +$vsW = [WinRpa.RpaUser32Click]::GetSystemMetrics(78) +$vsH = [WinRpa.RpaUser32Click]::GetSystemMetrics(79) +$inVs = ($rect.X -ge $vsX) -and ($rect.Y -ge $vsY) -and (($rect.X + $rect.Width) -le ($vsX + $vsW)) -and (($rect.Y + $rect.Height) -le ($vsY + $vsH)) +$offscreen = $el.Current.IsOffscreen -or $rect.Width -le 0 -or $rect.Height -le 0 -or (-not $inVs) +if ($offscreen) { + # 窗口可能被最小化或移出屏幕:还原并移回可视区后重取坐标 + $walker0 = [System.Windows.Automation.TreeWalker]::ControlViewWalker + $anc0 = $el + $topHwnd = [IntPtr]::Zero + while ($null -ne $anc0) { + $h0 = $anc0.Current.NativeWindowHandle + if ($h0 -ne 0) { $topHwnd = [IntPtr]$h0; break } + $anc0 = $walker0.GetParent($anc0) + } + if ($topHwnd -ne [IntPtr]::Zero) { + [WinRpa.RpaUser32Click]::ShowWindow($topHwnd, 9) | Out-Null + Start-Sleep -Milliseconds 600 + $sw3 = [WinRpa.RpaUser32Click]::GetSystemMetrics(0) + $sh3 = [WinRpa.RpaUser32Click]::GetSystemMetrics(1) + $w3 = [Math]::Min(1400, $sw3 - 120) + $h3 = [Math]::Min(820, $sh3 - 120) + [WinRpa.RpaUser32Click]::SetWindowPos($topHwnd, [IntPtr]::Zero, 60, 60, $w3, $h3, 0x0040) | Out-Null + Start-Sleep -Milliseconds 600 + $rect = $el.Current.BoundingRectangle + $inVs = ($rect.X -ge $vsX) -and ($rect.Y -ge $vsY) -and (($rect.X + $rect.Width) -le ($vsX + $vsW)) -and (($rect.Y + $rect.Height) -le ($vsY + $vsH)) + $offscreen = $el.Current.IsOffscreen -or $rect.Width -le 0 -or $rect.Height -le 0 -or (-not $inVs) + } +} $method = "coordinate_click" $ok = $false if (-not $offscreen) { @@ -358,3 +388,4 @@ register("Element_WaitElementGround", waitElementGround); +