// Add this method for those situation where we need longer timeout to wait for window! public static SUIWindow WaitingForWindow(string caption, int timeout) { SUIWindow waitingForwin = null; try { while (waitingForwin == null && timeout-- > 0) { SUISleeper.Sleep(1000); waitingForwin = DesktopWindow.FindChildWindowByText(caption); } } catch (Exception e) { throw new SUIGetWindowException(e); } return(waitingForwin); }
public static SUIWindow WaitingForWindow(string matchCaption, bool isRegularExpression, int timeout) { if (!isRegularExpression) { return(WaitingForWindow(matchCaption, timeout)); } SUIWindow waitingForwin = null; Regex reg = new Regex(matchCaption); while (waitingForwin == null && timeout-- > 0) { SUISleeper.Sleep(1000); if (matchCaption.Equals(string.Empty)) { waitingForwin = DesktopWindow.FindChildWindowByText(matchCaption); SUIWindow temp = SUIWindow.GetForegroundWindow(); if (!waitingForwin.WindowHandle.Equals(temp.WindowHandle)) { waitingForwin = temp; } } else { foreach (SUIWindow win in DesktopWindow.Items) { if (SUIWinAPIs.IsWindowVisible(win.WindowHandle) && reg.IsMatch(win.WindowText)) { waitingForwin = win; break; } } } } return(waitingForwin); }