/// <inheritdoc /> public override bool HandleDialog(Window window) { if (CanHandleDialog(window)) { window.ToFront(); window.SetActivate(); var inputBoxHwnd = new Hwnd(NativeMethods.GetChildWindowHwnd(window.Hwnd, "Edit")); if (inputBoxHwnd.hwnd == IntPtr.Zero) { return(false); } if (_cancel) { window.ForceClose(); } else { inputBoxHwnd.SetFocus(); inputBoxHwnd.SendString(_input); var okButton = new WinButton(1, window.Hwnd); okButton.Click(); } return(true); } return(false); }
public override bool HandleDialog(Window window) { if (IsPromptDialog(window)) { window.ToFront(); window.SetActivate(); Window inputBox = new Window(NativeMethods.GetChildWindowHwnd(window.Hwnd, "Edit")); if (inputBox.Hwnd != IntPtr.Zero) { if (_cancel) { window.ForceClose(); } else { NativeMethods.SetActiveWindow(inputBox.Hwnd); System.Windows.Forms.SendKeys.SendWait(_input); System.Windows.Forms.SendKeys.SendWait("{ENTER}"); } return(true); } } return(false); }
public override bool HandleDialog(Window window) { if (IsPromptDialog(window)) { window.ToFront(); window.SetActivate(); Window inputBox = new Window(NativeMethods.GetChildWindowHwnd(window.Hwnd, "Edit")); if (inputBox.Hwnd != IntPtr.Zero) { if (_cancel) { window.ForceClose(); } else { NativeMethods.SetActiveWindow(inputBox.Hwnd); System.Windows.Forms.SendKeys.SendWait(_input); System.Windows.Forms.SendKeys.SendWait("{ENTER}"); } return true; } } return false; }
private bool HandledFileDownloadDialog(Window window) { if (!HasHandledFileDownloadDialog && IsFileDownloadDialog(window)) { window.ToFront(); window.SetActivate(); DownloadProgressDialog = new Window(window.ParentHwnd); var btn = GetButtonToPress(window); btn.Click(); HasHandledFileDownloadDialog = !Exists(window); if (HasHandledFileDownloadDialog) { Logger.LogAction("Download started at {0}", DateTime.Now.ToLongTimeString()); Logger.LogAction("Clicked {0}", _optionEnum); } return(true); } return(false); }
/// <summary> /// Handles the dialogs to download (and save) a file /// Mainly used internally by WatiN. /// </summary> /// <param name="window">The window.</param> /// <returns></returns> public override bool HandleDialog(Window window) { // This if handles the File download dialog if (!HasHandledFileDownloadDialog && IsFileDownloadDialog(window)) { window.ToFront(); window.SetActivate(); DownloadProgressDialog = new Window(window.ParentHwnd); WinButton btn = GetButtonToPress(window); btn.Click(); hasHandledFileDownloadDialog = !Exists(window); if (HasHandledFileDownloadDialog) { Logger.LogAction("Download started at " + DateTime.Now.ToLongTimeString()); Logger.LogAction("Clicked " + _optionEnum.ToString()); } return(true); } // This if handles the download progress dialog if (IsDownloadProgressDialog(window)) { DownloadProgressDialog = window; WinButton openOrRun = new WinButton(4377, new Hwnd(window.Hwnd)); if (openOrRun.Enabled) { WinButton close = new WinButton(2, new Hwnd(window.Hwnd)); close.Click(); SimpleTimer timer = new SimpleTimer(5); while (!timer.Elapsed && window.Exists()) { Thread.Sleep(200); } } return(true); } // This if handles the File save as dialog if (IsFileSaveDialog(window)) { Logger.LogAction("Saving Download file as " + saveAsFilename); DownloadProgressDialog = new Window(window.ParentHwnd); HandleFileSaveDialog(window); return(true); } // Window is not a dialog this handler can handle. return(false); }
/// <summary> /// Handles the dialogs to download (and save) a file /// Mainly used internally by WatiN. /// </summary> /// <param name="window">The window.</param> /// <returns></returns> public override bool HandleDialog(Window window) { // This if handles the File download dialog if (!HasHandledFileDownloadDialog && IsFileDownloadDialog(window)) { window.ToFront(); window.SetActivate(); DownloadProgressDialog = new Window(window.ParentHwnd); WinButton btn = GetButtonToPress(window); btn.Click(); hasHandledFileDownloadDialog = !Exists(window); if (HasHandledFileDownloadDialog) { Logger.LogAction("Download started at " + DateTime.Now.ToLongTimeString()); Logger.LogAction("Clicked " + _optionEnum.ToString()); } return true; } // This if handles the download progress dialog if (IsDownloadProgressDialog(window)) { DownloadProgressDialog = window; WinButton openOrRun= new WinButton(4377, new Hwnd(window.Hwnd)); if (openOrRun.Enabled) { WinButton close = new WinButton(2, new Hwnd(window.Hwnd)); close.Click(); SimpleTimer timer = new SimpleTimer(5); while (!timer.Elapsed && window.Exists()) { Thread.Sleep(200); } } return true; } // This if handles the File save as dialog if (IsFileSaveDialog(window)) { Logger.LogAction("Saving Download file as " + saveAsFilename); DownloadProgressDialog = new Window(window.ParentHwnd); HandleFileSaveDialog(window); return true; } // Window is not a dialog this handler can handle. return false; }