private static IntPtr GetCheckBox(List <IntPtr> childs, IntPtr dialogHandle) { IntPtr leftButton = IntPtr.Zero; User32.RECT rectFlag = new User32.RECT(); rectFlag.Top = 100000; IntPtr leftChildButton = IntPtr.Zero; foreach (IntPtr item in childs) { string className = User32.GetClassName(item); if (_checkBoxClassName == className.ToLower()) { User32.RECT rect = new User32.RECT(); User32.GetWindowRect(item, out rect); if (rect.Top < rectFlag.Top) { rectFlag.Top = rect.Top; leftButton = item; } } } return(leftButton); }
private 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 ("Button" == className) { User32.RECT rect = new User32.RECT(); User32.GetWindowRect(item, out rect); if (rect.Left < rectFlag.Left) { rectFlag.Left = rect.Left; leftButton = item; } } } return(leftButton); }
private static 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); } } } }
private static Dictionary<SecurityDialog, DateTime> GetSecurityDialogs(Process[] outlookProcess) { Dictionary<SecurityDialog, DateTime> local = new Dictionary<SecurityDialog, DateTime>(); User32.EnumDelegate filter = delegate(IntPtr hWnd, int lParam) { User32.GetClassName(hWnd, _strbClassName, _strbClassName.Capacity + 1); string className = _strbClassName.ToString(); User32.GetWindowText(hWnd, _strbCaption, _strbCaption.Capacity + 1); string caption = _strbCaption.ToString(); if((_dialogClassName == className.ToString()) && (User32.IsWindowVisible(hWnd))) { uint processID = 0; User32.GetWindowThreadProcessId(hWnd, out processID); foreach (Process process in outlookProcess) { if (processID == process.Id) { User32.RECT rect = new User32.RECT(); User32.GetWindowRect(hWnd, out rect); local.Add(new SecurityDialog(hWnd, caption, className, new Rect(rect)), DateTime.Now); break; } } } return true; }; User32.EnumDesktopWindows(IntPtr.Zero, filter, IntPtr.Zero); foreach (KeyValuePair<SecurityDialog, DateTime> item in local) { SecurityDialog existing = GetDialogFromHandle(_listDialogs, item.Key.Handle); if (null == existing) _listDialogs.Add(item.Key, item.Value); } List<SecurityDialog> toDelete = new List<SecurityDialog>(); foreach (KeyValuePair<SecurityDialog, DateTime> item in _listDialogs) { SecurityDialog existing = GetDialogFromHandle(_listDialogs, item.Key.Handle); if (null == existing) toDelete.Add(item.Key); } foreach (SecurityDialog item in toDelete) _listDialogs.Remove(item); return _listDialogs; }
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; }
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); }
void _timer_Elapsed(object sender, ElapsedEventArgs e) { if (!_enabled) { return; } try { TryGetOutlookSecurityDialogHandles(); foreach (SecurityDialog item in _listDialogs) { List <IntPtr> childWindows = User32.GetChildWindows(item.Handle); if (!IncludeOneComboBox(childWindows)) { continue; } IntPtr checkBox = GetCheckBox(childWindows, item.Handle); string checkBoxText = User32.GetWindowText(checkBox); if ((IntPtr.Zero != checkBox) && (!string.IsNullOrEmpty(checkBoxText))) { PostSendClick(checkBox); } IntPtr leftButton = GetLeftButton(childWindows, item.Handle); string buttonText = User32.GetWindowText(leftButton); if ((IntPtr.Zero != leftButton) && (!string.IsNullOrEmpty(buttonText))) { PostSendClick(leftButton); } if ((null != Action) && (null != checkBox) && (null != 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 (null != 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))) { Action(item, securityCheckbox, securityButton); } } } } catch (Exception exception) { _enabled = false; if (null != ErrorOccured) { ErrorOccured(exception); } } }
private List<SecurityDialog> GetSecurityDialogs(Process[] outlookProcess) { _listDialogs.Clear(); User32.EnumDelegate filter = delegate(IntPtr hWnd, int lParam) { User32.GetClassName(hWnd, _strbClassName, _strbClassName.Capacity + 1); string className = _strbClassName.ToString(); User32.GetWindowText(hWnd, _strbCaption, _strbCaption.Capacity + 1); string caption = _strbCaption.ToString(); if(("#32770" == className.ToString()) && (User32.IsWindowVisible(hWnd))) { uint processID = 0; User32.GetWindowThreadProcessId(hWnd, out processID); foreach (Process process in outlookProcess) { if (processID == process.Id) { User32.RECT rect = new User32.RECT(); User32.GetWindowRect(hWnd, out rect); _listDialogs.Add(new SecurityDialog(hWnd, caption, className, new Rect(rect))); break; } } } return true; }; User32.EnumDesktopWindows(IntPtr.Zero, filter, IntPtr.Zero); return _listDialogs; }
private IntPtr GetCheckBox(List<IntPtr> childs, IntPtr dialogHandle) { IntPtr leftButton = IntPtr.Zero; User32.RECT rectFlag = new User32.RECT(); rectFlag.Top = 100000; IntPtr leftChildButton = IntPtr.Zero; foreach (IntPtr item in childs) { string className = User32.GetClassName(item); if ("Button" == className) { User32.RECT rect = new User32.RECT(); User32.GetWindowRect(item, out rect); if (rect.Top < rectFlag.Top) { rectFlag.Top = rect.Top; leftButton = item; } } } return leftButton; }
private void PostSendClick(IntPtr handle) { User32.RECT rect = new User32.RECT(); User32.GetWindowRect(handle, out rect); User32.MouseClick(rect.Left + 15, rect.Top + 15); return; }
void _timer_Elapsed(object sender, ElapsedEventArgs e) { if (!_enabled) return; try { TryGetOutlookSecurityDialogHandles(); foreach (SecurityDialog item in _listDialogs) { List<IntPtr> childWindows = User32.GetChildWindows(item.Handle); if (!IncludeOneComboBox(childWindows)) continue; IntPtr checkBox = GetCheckBox(childWindows, item.Handle); string checkBoxText = User32.GetWindowText(checkBox); if ((IntPtr.Zero != checkBox) && (!string.IsNullOrEmpty(checkBoxText))) PostSendClick(checkBox); IntPtr leftButton = GetLeftButton(childWindows, item.Handle); string buttonText = User32.GetWindowText(leftButton); if ((IntPtr.Zero != leftButton) && (!string.IsNullOrEmpty(buttonText))) PostSendClick(leftButton); if ((null != Action) && (null != checkBox) && (null != 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 (null != 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))) Action(item, securityCheckbox, securityButton); } } } catch (Exception exception) { _enabled = false; if (null != ErrorOccured) ErrorOccured(exception); } }
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); }
private static 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); } } } } }