コード例 #1
0
        /// <summary>
        /// Called by the constructor to start watching popups
        /// on a separate thread.
        /// </summary>
        private void Start()
        {
            while (_keepRunning)
            {
                if (MainWindow.Exists())
                {
                    var winEnumerator = new WindowsEnumerator();
                    var windows       = winEnumerator.GetWindows(win => true);

                    foreach (var window in windows)
                    {
                        if (!_keepRunning)
                        {
                            return;
                        }
                        HandleWindow(window);
                    }

                    // Keep DialogWatcher responsive during 1 second sleep period
                    var count = 0;
                    while (_keepRunning && count < 5)
                    {
                        Thread.Sleep(200);
                        count++;
                    }
                }
                else
                {
                    _keepRunning = false;
                }
            }
        }
コード例 #2
0
        public HtmlDialogCollection(IntPtr hWnd, bool waitForComplete)
        {
            findBy = Find.Any;
            this.waitForComplete = waitForComplete;
            htmlDialogs          = new List <HtmlDialog>();

            var toplevelWindow = new Window(hWnd).ToplevelWindow;

            var windows = new WindowsEnumerator();
            var popups  = windows.GetWindows(window => window.ParentHwnd == toplevelWindow.Hwnd && NativeMethods.CompareClassNames(window.Hwnd, "Internet Explorer_TridentDlgFrame"));

            foreach (var window in popups)
            {
                var htmlDialog = new HtmlDialog(window.Hwnd);
                htmlDialogs.Add(htmlDialog);
            }
        }
コード例 #3
0
        public HtmlDialogCollection(IntPtr hWnd, bool waitForComplete)
        {
            findBy = Find.Any;
            this.waitForComplete = waitForComplete;
            var iesWindowHelper = new IESWindowHelper(hWnd);

            htmlDialogs = new List <HtmlDialog>();

            var windows = new WindowsEnumerator();
            var popups  = windows.GetWindows(window => NativeMethods.CompareClassNames(window.Hwnd, "Internet Explorer_TridentDlgFrame"));

            foreach (var window in popups)
            {
                if (!iesWindowHelper.IsChildWindow(window))
                {
                    continue;
                }

                var htmlDialog = new HtmlDialog(window.Hwnd);
                htmlDialogs.Add(htmlDialog);
            }
        }