如何使用UIAutomation或White启用按钮 [英] How to enable a button using UIAutomation or White

查看:242
本文介绍了如何使用UIAutomation或White启用按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使安装向导自动化,并且需要单击未启用的按钮.

I'm trying to automate an installation wizard and I needed to click on a button that is not enabled.

我知道可以使用Windows消息完成此操作,但是我想知道是否已经在White或UIAutomation中对此提供支持

I know that this can be done using Windows Messages, but I was wondering if there is already support in White or UIAutomation for this

作为参考,这不起作用:

For reference this doesn't work:

var invoke =  (System.Windows.Automation.InvokePattern)setup.button("Next >").AutomationElement.GetCurrentPattern(System.Windows.Automation.InvokePattern.Pattern);  
invoke.Invoke();

也不是

var guiAutomation = new API_GuiAutomation("msiexec");  
var setup = guiAutomation.windows()[0]; 
setup .bringToFront(); 
setup .button("Next >").mouse().click();  // this will work
setup .button("Next >").mouse().click();  // this will not work since the button is not enabled

上面的示例使用了我添加到 O2平台的基于白色的API(请参阅此处的

The example above uses the White based API I added to the O2 Platform (see here an example of automating notepad)

推荐答案

我不相信您可以使用UIAutomation来做到这一点:您要的是超出UIAutomation框架的范围.它旨在让您使用与鼠标和键盘相同的代码进行处理.它不是设计为处理UI状态的常规方法.

I don't believe you can do this with UIAutomation: what you're asking for is something that goes beyond the remit of the UIAutomation framework. It is intended to let you do with code the same that you could otherwise do with mouse and keyboard. It is not designed as a general means of manipulating UI state.

这篇关于如何使用UIAutomation或White启用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆