Exemplo n.º 1
0
        private static IntPtr GetLeftButton(List <IntPtr> childs, IntPtr dialogHandle)
        {
            IntPtr leftButton = IntPtr.Zero;

            User32.RECT rectFlag = new User32.RECT();
            rectFlag.Left = 100000;
            IntPtr leftChildButton = IntPtr.Zero;

            foreach (IntPtr item in childs)
            {
                string className = User32.GetClassName(item);
                if (_buttonClassName == className.ToLower())
                {
                    User32.RECT rect = new User32.RECT();
                    User32.GetWindowRect(item, out rect);
                    if (rect.Left < rectFlag.Left)
                    {
                        rectFlag.Left = rect.Left;
                        leftButton    = item;
                    }
                }
            }
            return(leftButton);
        }
Exemplo n.º 2
0
 private static void DoMouseMoveClick(IntPtr handle)
 {
     User32.RECT rect = new User32.RECT();
     User32.GetWindowRect(handle, out rect);
     User32.DoMouseMoveClick(rect.Left + 15, rect.Top + 15);
 }
Exemplo n.º 3
0
        private void ProceedSuppress()
        {
            lock (_lock)
            {
                TryGetOutlookSecurityDialogHandles();

                foreach (KeyValuePair <SecurityDialog, DateTime> item in _listDialogs)
                {
                    List <IntPtr> childWindows = User32.GetChildWindows(item.Key.Handle);
                    if (!ContainsOneComboBoxOrRichEdit(childWindows))
                    {
                        continue;
                    }

                    if ((DateTime.Now - item.Value).TotalSeconds >= _timeOutSeconds)
                    {
                        if (!item.Key.ExceptionThrown)
                        {
                            if (null != _onError)
                            {
                                _onError(new TimeoutException(String.Format(_timeOutMessage, item.Key.Handle)));
                            }
                            item.Key.ExceptionThrown = true;
                        }
                        continue;
                    }

                    IntPtr checkBox     = GetCheckBox(childWindows, item.Key.Handle);
                    string checkBoxText = User32.GetWindowText(checkBox);
                    if ((IntPtr.Zero != checkBox) && (!string.IsNullOrEmpty(checkBoxText)))
                    {
                        if (!item.Key.CheckBoxPassed)
                        {
                            DoControlClick(checkBox);
                        }
                        item.Key.CheckBoxPassed = true;
                    }

                    IntPtr leftButton = GetLeftButton(childWindows, item.Key.Handle);
                    string buttonText = User32.GetWindowText(leftButton);
                    if ((IntPtr.Zero != leftButton) && (!string.IsNullOrEmpty(buttonText)))
                    {
                        if (ContainsOneVisibleProgress(childWindows, item.Key.Handle) & ((DateTime.Now - item.Value).TotalSeconds <= _delaySeconds))
                        {
                            continue;
                        }
                        EnableControl(leftButton);
                        DoControlClick(leftButton);
                    }

                    if ((null != _onAction) && (null != checkBox) && (IntPtr.Zero != leftButton) && (checkBox != leftButton))
                    {
                        SecurityDialogCheckBox   securityCheckbox = null;
                        SecurityDialogLeftButton securityButton   = null;
                        if (null != checkBox)
                        {
                            User32.RECT rect = new User32.RECT();
                            User32.GetWindowRect(checkBox, out rect);
                            securityCheckbox = new SecurityDialogCheckBox(checkBox, User32.GetWindowText(checkBox), new Rect(rect));
                        }

                        if (IntPtr.Zero != leftButton)
                        {
                            User32.RECT rect = new User32.RECT();
                            User32.GetWindowRect(checkBox, out rect);
                            securityButton = new SecurityDialogLeftButton(leftButton, User32.GetWindowText(leftButton), new Rect(rect));
                        }

                        if ((!string.IsNullOrEmpty(checkBoxText)) && (!string.IsNullOrEmpty(buttonText)))
                        {
                            _onAction(item.Key, securityCheckbox, securityButton);
                        }
                    }
                }
            }
        }