From 124f11bd6bd9425f57a8549782fe10c7760573e9 Mon Sep 17 00:00:00 2001 From: yu <191972707@qq.com> Date: Thu, 5 Nov 2026 13:43:44 +0800 Subject: [PATCH] fix: Dialog_Notice/MsgBox MessageBox options arg - invalid HelpButton value Previous topmost attempt passed 'HelpButton' in the MessageBoxOptions position of MessageBox::Show, so PowerShell failed at runtime with "cannot convert value HelpButton to type System.Windows.Forms.MessageBoxOptions" (reproduced in flow run: notice node failed at char 196). Now passes the documented MB_TOPMOST flag (MessageBoxOptions)262144 as the 6th argument, keeping the six-argument overload (OK / Information / Button1 / topmost). --- packages/rpa-core/src/capabilities/desktop.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/rpa-core/src/capabilities/desktop.ts b/packages/rpa-core/src/capabilities/desktop.ts index 6e7a828..77097e5 100644 --- a/packages/rpa-core/src/capabilities/desktop.ts +++ b/packages/rpa-core/src/capabilities/desktop.ts @@ -154,7 +154,9 @@ const notice: CapabilityHandler = async (_ctx, _node, args) => { // MessageBox 阻塞等用户点确定,同样不能吃 powershell() 默认 30s 超时;且 MB_TOPMOST 保证弹窗不被主窗口盖住 const waitSeconds = number(args, ["wait_time", "waitTime", "timeout"], 600); const timeoutMs = Math.max(10000, Math.round(waitSeconds * 1000)); - await powershell(`Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.MessageBox]::Show(${psString(content)},${psString(title)},'OK','Information','Button1','HelpButton',1) | Out-Null`, timeoutMs); + // MessageBoxOptions 第 6 参数用 MB_TOPMOST(0x40000=262144) 标志位实现置顶;此前误传 'HelpButton'(图标枚举值) + // 导致 PowerShell 类型转换失败「无法将 HelpButton 转换为 MessageBoxOptions」 + await powershell(`Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.MessageBox]::Show(${psString(content)},${psString(title)},'OK','Information','Button1',[System.Windows.Forms.MessageBoxOptions]262144) | Out-Null`, timeoutMs); return true; };