/// <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; }
/// <summary> /// Handles the File upload dialog. /// </summary> /// <param name="window">The window.</param> /// <returns></returns> public override bool HandleDialog(Window window) { if (CanHandleDialog(window)) { var fileNameHandle = NativeMethods.GetChildWindowHwnd(window.Hwnd, "Edit"); var fileNameHwnd = new Hwnd(fileNameHandle); fileNameHwnd.SetFocus(); fileNameHwnd.SendString(fileName); var openButton = new WinButton(1, window.Hwnd); openButton.Click(); return true; } return false; }
/// <summary> /// Handles the logon dialog by filling in the username and password. /// </summary> /// <param name="window">The window.</param> /// <returns></returns> public override bool HandleDialog(Window window) { if (CanHandleDialog(window)) { // Find Handle of the "Frame" and then the combo username entry box inside the frame var systemCredentialsHwnd = GetSystemCredentialsHwnd(window); NativeMethods.SetActiveWindow(systemCredentialsHwnd); Thread.Sleep(50); NativeMethods.SetForegroundWindow(systemCredentialsHwnd); Thread.Sleep(50); var windowEnumarator = new WindowsEnumerator(); // Find input fields var edits = windowEnumarator.GetChildWindows(systemCredentialsHwnd, "Edit"); // Enter userName var hwnd = new Hwnd(edits[0].Hwnd); hwnd.SetFocus(); hwnd.SendString(userName); // Enter password hwnd = new Hwnd(edits[1].Hwnd); hwnd.SetFocus(); hwnd.SendString(password); // Click OK button new WinButton(1, window.Hwnd).Click(); return true; } return false; }
private void HandleFileSaveDialog(Window window) { var fileNameHandle = NativeMethods.GetChildWindowHwnd(window.Hwnd, "Edit"); var fileNameHwnd = new Hwnd(fileNameHandle); fileNameHwnd.SetFocus(); fileNameHwnd.SendString(saveAsFilename); var openButton = new WinButton(1, window.Hwnd); openButton.Click(); }