public void Close() { Window dialog = new Window(hwnd); if (dialog.Visible) { dialog.ForceClose(); } }
public override bool HandleDialog(Window window) { if (IsReplaceFormAlertHandler(window)) { ButtonToPush(window).Click(); return true; } return false; }
public virtual bool IsSaveFileDialog(Window window) { bool val = false; if ((window.StyleInHex == dialogStyle)) { val = true; } return val; }
public override bool HandleDialog(Window window) { if (IsSecurityAlertDialog(window)) { ButtonToPush(window).Click(); return true; } return false; }
public override bool HandleDialog(Window window) { if (IsSaveFileDialog(window)) { NativeMethods.SetForegroundWindow(window.Hwnd); Thread.Sleep(50); NativeMethods.SetActiveWindow(window.Hwnd); Thread.Sleep(50); ButtonToPush(window).Click(); return true; } return false; }
public virtual bool IsSaveFileDialog(Window window) { bool val = false; if ((window.StyleInHex == dialogStyle)) { // determain if we are in the correct dialog... (There are a few with the same style) IntPtr hWnd = NativeMethods.GetDlgItem(window.Hwnd, (int)DialogText.textControl); string dialogText = NativeMethods.GetWindowText(hWnd); if (dialogText.ToLower().Contains("read only")) { val = true; } } return val; }
public virtual bool IsSaveFileDialog(Window window) { bool val = false; if ((window.StyleInHex == dialogStyle)) { // determain if we are in the correct save dialog... (There are a few) IntPtr hWnd = NativeMethods.GetDlgItem(window.Hwnd, (int)DialogText.textControl); string dialogText = NativeMethods.GetWindowText(hWnd); if (dialogText.Contains("Do you want to save the changes")) { val = true; } } return val; }
public override bool HandleDialog(Window window) { if (IsLogonDialog(window)) { // Find Handle of the "Frame" and then the combo username entry box inside the frame IntPtr inputFrameHandle = NativeMethods.GetChildWindowHwnd(window.Hwnd, "SysCredential"); IntPtr usernameControlHandle = NativeMethods.GetChildWindowHwnd(inputFrameHandle, "ComboBoxEx32"); NativeMethods.SetActiveWindow(usernameControlHandle); Thread.Sleep(50); NativeMethods.SetForegroundWindow(usernameControlHandle); Thread.Sleep(50); System.Windows.Forms.SendKeys.SendWait(userName + "{TAB}"); Thread.Sleep(500); System.Windows.Forms.SendKeys.SendWait(password + "{ENTER}"); return true; } else if (IsInfoPathLogonDialog(window)) { // Find Handle of the "Frame" and then the combo username entry box inside the frame IntPtr inputFrameHandle = window.Hwnd; NativeMethods.SetActiveWindow(inputFrameHandle); Thread.Sleep(50); NativeMethods.SetForegroundWindow(inputFrameHandle); Thread.Sleep(50); System.Windows.Forms.SendKeys.SendWait(userName + "{TAB}"); Thread.Sleep(500); System.Windows.Forms.SendKeys.SendWait(password + "{ENTER}"); PushOkButton(window); return true; } return false; }
/// <summary> /// Determines whether the specified window is a logon dialog. /// </summary> /// <param name="window">The window.</param> /// <returns> /// <c>true</c> if the specified window is a logon dialog; otherwise, <c>false</c>. /// </returns> public virtual bool IsLogonDialog(Window window) { // If a logon dialog window is found hWnd will be set. return NativeMethods.GetChildWindowHwnd(window.Hwnd, "SysCredential") != IntPtr.Zero; }
private WinButton ButtonToPush(Window window) { return new WinButton((int)buttonToPush, window.Hwnd); }
public virtual bool IsInfoPathLogonDialog(Window window) { // If a logon dialog window is found hWnd will be set. return window.StyleInHex == "94C80084"; }
protected virtual bool IsReplaceFormAlertHandler(Window window) { System.Diagnostics.Debug.WriteLine(window.Title + "|" + window.StyleInHex + "|"); return window.Title.ToLower().Contains("conflict"); }
/// <summary> /// If the window is a dialog and visible, it will be passed to /// the registered dialog handlers. I none if these can handle /// it, it will be closed if <see cref="CloseUnhandledDialogs"/> /// is <c>true</c>. /// </summary> /// <param name="window">The window.</param> public void HandleWindow(Window window) { if (window.IsDialog()) { // Wait untill window is visible so all properties // of the window class (like Style and StyleInHex) // will return valid values. while (window.Visible == false) { Thread.Sleep(50); } // Lock the thread and see if a handler will handle // this dialog window lock (this) { foreach (IDialogHandler dialogHandler in handlers) { try { if (dialogHandler.HandleDialog(window)) { return; } } catch (Exception e) { lastException = e; } } // If no handler handled the dialog, see if it // should be close automatically. if (CloseUnhandledDialogs && !PopupDialog.IsWarningPopup(window.Hwnd, InfoPathWarningStyleInHex)) { window.ForceClose(); } } } }
private ItiN.WinButton ButtonToPush(Window window) { return new ItiN.WinButton((int)this._buttonToPush, window.Hwnd); }
public virtual bool IsSaveFileDialog(Window window) { bool val = false; if ((window.StyleInHex == dialogStyle)) { // determain if we are in the correct save dialog... (There are a few) IntPtr hWnd = NativeMethods.GetDlgItem(window.Hwnd, (int)DialogText.textControl); string dialogText = NativeMethods.GetWindowText(hWnd); if (dialogText.Contains("This form contains validation errors")) { val = true; System.Diagnostics.Debug.WriteLine("Form has validation errors. Maybe you forgot to complete all fields?"); } } return val; }
internal static bool IsWarningPopup(IntPtr hWnd, string infopathWarningStyle) { Window dialog = new Window(hWnd); if (dialog.StyleInHex == infopathWarningStyle) { return true; } else if (NativeMethods.GetChildWindowHwnd(dialog.Hwnd, "SysCredential") != IntPtr.Zero || dialog.StyleInHex == "94C80084") { return false; } else if (dialog.Title.Contains("Microsoft Office InfoPath")) { return true; } else { return false; } }
private void PushOkButton(Window window) { (new WinButton(1, window.Hwnd)).Click(); }
public string GetValue(string attributename) { string value = null; if (attributename.ToLower().Equals("title")) { try { Window dialog = new Window(hwnd); value = dialog.Title; } catch { } } else { throw new InvalidAttributException(attributename, "PopupDialog"); } return value; }
protected virtual bool IsSecurityAlertDialog(Window window) { return window.StyleInHex == SecurityAlertDialogStyle; }
public abstract bool HandleDialog(Window window);