我正在考虑将 White 用于我的简单 windows ui 自动化。首先,我使用System.Diagnostics.Process
. 当外部应用程序打开时会给我一个对话框,用户在其中插入一些文本并单击 OK 按钮。我需要等到对话框关闭或检测到单击确定按钮。我所需要的只是一些迹象表明用户已完成该对话框,我可以继续我的自动化任务。
有什么办法可以用白做吗?也欢迎任何其他选择!
我正在考虑将 White 用于我的简单 windows ui 自动化。首先,我使用System.Diagnostics.Process
. 当外部应用程序打开时会给我一个对话框,用户在其中插入一些文本并单击 OK 按钮。我需要等到对话框关闭或检测到单击确定按钮。我所需要的只是一些迹象表明用户已完成该对话框,我可以继续我的自动化任务。
有什么办法可以用白做吗?也欢迎任何其他选择!
您可以在该对话框上设置标题,并安排计时器在主窗口的子窗口中查找子窗口。如果没有找到,您可以继续。 应该工作。
另一种方式:
using System.Windows.Automation;
Automation.AddAutomationEventHandler(
WindowPattern.WindowClosedEvent,
AutomationElement.RootElement, // set correct value here
TreeScope.Children, // check the value is correct
(sender, e) =>
{
var element = sender as AutomationElement;
if (element.Current.Name != "Form Title")
return;
Automation.RemoveAllEventHandlers(); // remove event handler
// Your code here
// CodeToRunAfterWindowClosed();
});