From 9d996f137b1a1d6964dfecdcd0a8ccc6f11883b6 Mon Sep 17 00:00:00 2001 From: yu <191972707@qq.com> Date: Wed, 28 Oct 2026 15:49:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A1=A5=E9=BD=90=20setValue/getValue?= =?UTF-8?q?=20=E8=84=9A=E6=9C=AC=E7=BC=BA=E5=A4=B1=E7=9A=84=20try-catch=20?= =?UTF-8?q?=E9=97=AD=E5=90=88=EF=BC=8C=E4=BF=AE=E5=A4=8D=20PowerShell=20?= =?UTF-8?q?=E8=AF=AD=E6=B3=95=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/capabilities/desktop-uia.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/capabilities/desktop-uia.ts b/src/main/capabilities/desktop-uia.ts index 89ffd74..7626b41 100644 --- a/src/main/capabilities/desktop-uia.ts +++ b/src/main/capabilities/desktop-uia.ts @@ -254,13 +254,14 @@ if (-not $offscreen) { $rect2 = $el.Current.BoundingRectangle Write-Output (@{ clicked = $ok; method = $method; name = $el.Current.Name; x = [int]$rect2.X; y = [int]$rect2.Y; w = [int]$rect2.Width; h = [int]$rect2.Height } | ConvertTo-Json -Compress)`; } -function setValueScript(t: UiaTarget, value: string): string { +export function setValueScript(t: UiaTarget, value: string): string { const s = t.selector; return `${UIA_USING} ${FIND_HELPER} try { $parent = Find-RpaWindow ${psString(s.window ?? "")} $el = Find-RpaElement $parent ${psString(s.name ?? "")} ${psString(s.id ?? "")} ${psString(s.type ?? "")} ${psString(s.className ?? "")} ${s.index} +} catch { $el = $null } if ($null -eq $el) { Write-Output "JSON_NOT_FOUND"; exit 0 } $value = ${psString(value)} $method = "value_pattern" @@ -297,6 +298,7 @@ ${FIND_HELPER} try { $parent = Find-RpaWindow ${psString(s.window ?? "")} $el = Find-RpaElement $parent ${psString(s.name ?? "")} ${psString(s.id ?? "")} ${psString(s.type ?? "")} ${psString(s.className ?? "")} ${s.index} +} catch { $el = $null } if ($null -eq $el) { Write-Output "JSON_NOT_FOUND"; exit 0 } $value = $el.Current.Name try { $vp = $el.GetCurrentPattern([System.Windows.Automation.ValuePattern]::Pattern); $value = $vp.Value } catch {} @@ -389,3 +391,5 @@ register("Element_WaitElementGround", waitElementGround); + +