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); } } } }
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 Suppress_OnAction(SecurityDialog dialog, SecurityDialogCheckBox targetBox, SecurityDialogLeftButton targetButton) { Console.WriteLine("Suppress_OnAction:{0}{1}{2}", Environment.NewLine, dialog, Environment.NewLine, targetButton); }
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 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); } } } } }