首页 > 解决方案 > 如何使用powershell等待uia自动化中的按钮

问题描述

目前我想等着看窗口中是否启用了按钮,我可以看到 uiautomation.dll 支持许多等待命令行开关。但无法使其在窗口内工作。我正在尝试的命令。

等待窗口的工作代码

Wait-UIAwindow -name "WindowMessageBox"

当我等待按钮时不在窗口内工作

Get-UIAwindow -name "WindowMessageBox" | Wait-uiabuttonisenabled -automationid "ButtonID" 

启用按钮后获得结果有什么帮助吗?

标签: powershellui-automation

解决方案


Get-UiaButton -AutomationId '1001' -Class 'Button' -Name 'Browse...' | Wait-UiaButtonIsEnabled  -Seconds 3000| Invoke-UIAButtonClick

这对我有用,没有-automationid参数,Wait-uiabuttonisenabled所以必须在我的代码中使用流水线处理它,而不是 Invoke-UIAButtonClick你可以放置( Get-UIAwindow -name "WindowMessageBox" )


推荐阅读