예제 #1
0
        public static MessageBoxProxy WaitMessageBoxChild(this AutomationElement element, int?timeOut = null)
        {
            var parentWin = WindowProxy.Normalize(element);

            var win = parentWin.WaitChild(a => a.Current.ControlType == ControlType.Window && a.Current.ClassName == "#32770", timeOut);

            return(new MessageBoxProxy(win));
        }
예제 #2
0
        public static MessageBoxProxy TryMessageBoxChild(this AutomationElement element)
        {
            var parentWin = WindowProxy.Normalize(element);

            var win = parentWin.TryChild(a => a.Current.ControlType == ControlType.Window && a.Current.ClassName == "#32770");

            if (win != null)
            {
                return(new MessageBoxProxy(win));
            }

            return(null);
        }
예제 #3
0
        public static AutomationElement CaptureChildWindow(this AutomationElement element, Action action, Func <string> actionDescription = null, int?timeOut = null)
        {
            if (actionDescription == null)
            {
                actionDescription = () => "Get Windows after";
            }

            var parentWindow = WindowProxy.Normalize(element);

            var previous = parentWindow.Children(a => a.Current.ControlType == ControlType.Window).Select(a => a.GetRuntimeId().ToString(".")).ToHashSet();

            action();

            AutomationElement newWindow = null;

            List <AutomationElement> currentWindows = new List <AutomationElement>();

            element.Wait(() =>
            {
                currentWindows = parentWindow.Children(a => a.Current.ControlType == ControlType.Window);
                newWindow      = currentWindows.FirstOrDefault(a => !previous.Contains(a.GetRuntimeId().ToString(".")));

                MessageBoxProxy.ThrowIfError(newWindow);

                if (newWindow != null)
                {
                    return(true);
                }


                return(false);
            }, () => actionDescription() +
                         "\r\n\tcurrentWindows: " + currentWindows.ToString(a => NiceToString(a), "\r\n\t\t") +
                         "\r\n\tnewWindow: " + NiceToString(newWindow) +
                         "\r\n\tprevious: " + previous.ToString(a => a, " ")
                         , timeOut ?? CapturaWindowTimeout);
            return(newWindow);
        }