Jun 30, 2010 at 4:04 AM
Edited Jun 30, 2010 at 5:40 AM
Actually I found another solution: use basic elements of MS UI Automation to create a 'WinWait' method.
Here is my code:
//This method will check whether the window exist for every 200ms
static public bool WinWait(string windowTitle, int timeOut)
Stopwatch stopWatch = new Stopwatch();
//If elapsed time is longer than timeOut value, break the loop and reture false
if (stopWatch.ElapsedMilliseconds > timeOut)
AutomationElement wantedWindow = AutomationElement.RootElement.FindFirst(TreeScope.Children,
new PropertyCondition(AutomationElement.NameProperty, windowTitle));
//If the wanted window exist, break the loop and reture true
if (wantedWindow != null)
I think the White framework should provide an easy way to handle the window waiting problem.
Take a look at an automation script 'AutoIt' (http://www.autoitscript.com/autoit3/index.shtml), it's a good example of how to make method names easy to understand.
You can simply read the name of methods and understand it's function: WinExist (check whether a window exist), WinWait, ...
ps: Does anyone have some experience on using AutoIt? I am thinking of whether I should initiate a project, which ports/recreates methods of AutoIt to .NET framework methods using UI Automation framework and Win32 APIs.