开发者

C# wait user interaction with White

Im thinking of using White for my simple windos ui automation. First i run external application from my application using System.Diagnostics.Process. When the external application opens is going to give me a dialog where the user has insert some text and click OK button. What i need is to wait until the dialog is closed or detect the OK button is cli开发者_JAVA百科cked. All i need is some indication that user is finished with that dialog and i can go on with my automation tasks.

Is there any way doing this with White? Any other options also welcome!


You can setup a title on that dialog, and schedule a timer to find a child window among Main window's children. If it's not found, you can proceed. Should work.


Another way:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜