2011-10-04 43 views
1

我正在考慮將White用於簡單的windos ui自動化。首先,我使用System.Diagnostics.Process從我的應用程序運行外部應用程序。當外部應用程序打開時會給我一個用戶插入一些文本並點擊確定按鈕的對話框。我需要等到對話框關閉或檢測到OK按鈕被點擊。我所需要的僅僅是說明用戶已經完成了該對話框,並且可以繼續執行自動化任務。C#等待用戶與白色的交互

有沒有辦法用White做這個?任何其他選項也歡迎!

回答

1

您可以在該對話框上設置標題,並安排定時器在主窗口的子項目中查找子窗口。如果找不到,可以繼續。 應該工作。

0

另一種方式:

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(); 
      });