/// <summary>
 /// Finds a OK Button in window
 /// </summary>
 /// <param name="window"></param>
 /// <returns></returns>
 private WinButton GetOKButton(Window window)
 {
     var windowButton = new WindowsEnumerator().GetChildWindows(window.Hwnd, w => w.ClassName == "Button" && new WinButton(w.Hwnd).Title == "OK").FirstOrDefault();
     if (windowButton == null)
         return null;
     else
         return new WinButton(windowButton.Hwnd);
 }
Ejemplo n.º 2
0
        public void PrintCart()
        {
            PrintLink.Click();
            Thread.Sleep(1000);

            WindowsEnumerator we = new WindowsEnumerator();
            Window printDialog = we.GetChildWindows(IntPtr.Zero, "#32770").FirstOrDefault(w => w.Title == "Print");
            if (printDialog != null) {
                WebBrowser.Current.DialogWatcher.HandleWindow(printDialog);
                WebBrowser.Current.DialogWatcher.Remove(handler);
            }
        }
Ejemplo n.º 3
0
        /// <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;
		}
Ejemplo n.º 4
0
		/// <summary>
		/// Called by the constructor to start watching popups
		/// on a separate thread.
		/// </summary>
		private void Start()
		{
			while (_keepRunning)
			{
                if (new Window(MainWindowHwnd).Exists())
                {
                    var winEnumerator = new WindowsEnumerator();
                    var windows = winEnumerator.GetWindows(win => true);
				
                    foreach (var window in windows)
                    {
                        if (!_keepRunning) return;
                        HandleWindow(new Window(window.Hwnd));
                    }

                    // Keep DialogWatcher responsive during 1 second sleep period
                    var count = 0;
                    while (_keepRunning && count < 5)
                    {
                        Thread.Sleep(200);
                        count++;
                    }
                }
                else
                {
                    _keepRunning = false;
                }
                
			}
		}