public static API_GuiAutomation_NativeMethods.Rect windowRectangle(this API_GuiAutomation guiAutomation, int windowHandle) { var rect = new API_GuiAutomation_NativeMethods.Rect(); API_GuiAutomation_NativeMethods.GetWindowRect(windowHandle, out rect); return(rect); }
public static List <Window> showDesktop(this API_GuiAutomation guiAutomation) { var desktopWindows = guiAutomation.desktopWindows(); foreach (var window in desktopWindows) { window.minimized(); } return(desktopWindows); }
public static Window firstWindow(this API_GuiAutomation guiAutomation) { guiAutomation.sleep(100); // needed on install wizards that change windows quite quickly var windows = guiAutomation.windows(); if (windows.size() > 0) { return(windows[0]); } return(null); }
public static Window desktopWindow(this API_GuiAutomation guiAutomation, string name) { foreach (var window in guiAutomation.desktopWindows()) { if (window.Name == name) { return(window); } } return(null); }
public static ListItem desktopIcon(this API_GuiAutomation guiAutomation, string name) { foreach (var icon in guiAutomation.desktopIcons()) { if (icon.Name == name) { return(icon); } } return(null); }
public static bool click_Button_in_Window(this API_GuiAutomation guiAutomation, string windowTitle, string buttonText, bool animateMouse, int timesToTry) { Func <bool> check = () => { var o2Timer = new O2Timer("click_Button_in_Window").start(); var scriptErrorWindow = guiAutomation.window(windowTitle); if (scriptErrorWindow.isNull()) { } //"didn't find window with title: {0}".error(windowTitle); else { var button = scriptErrorWindow.button(buttonText); if (button.isNull()) { } // "didn't find button with text: {0}".error(buttonText); else { "Found it: Clicking on button '{0}' in window '{1}' after {2} tries".debug(windowTitle, buttonText, timesToTry); if (animateMouse) { button.mouse(); } try { button.click(); } catch (Exception ex) { "[API_GuiAutomation][click_Button_in_Window] on or after clicking on button".error(ex.Message); } o2Timer.stop(); return(true); } } return(false); }; "Trying to find button '{0}' in window '{1}' for {2} tries".info(windowTitle, buttonText, timesToTry); for (int i = 0; i < timesToTry; i++) { var result = check(); if (result) { return(true); } } "Didn't find button '{0}' in window '{1}' after {2} tries".error(windowTitle, buttonText, timesToTry); return(false); }
public static PopUpMenu getContextMenu(this API_GuiAutomation guiAutomation) { try { var emptyWindow = guiAutomation.desktopWindow(""); return(emptyWindow.Popup); } catch { } return(null); }
public static API_GuiAutomation alwaysOnTop(this API_GuiAutomation guiAutomation, int windowHandle, bool value) { guiAutomation.window_Normal(windowHandle); // make sure the window is not minimized var HWND_TOPMOST = new HandleRef(null, new IntPtr(-1)); var HWND_NOTOPMOST = new HandleRef(null, new IntPtr(-2)); HandleRef hWndInsertAfter = value ? HWND_TOPMOST : HWND_NOTOPMOST; API_GuiAutomation_NativeMethods.SetWindowPos(windowHandle, hWndInsertAfter, 0, 0, 0, 0, 3); return(guiAutomation); }
public static Window window(this API_GuiAutomation guiAutomation, string windowName) { if (guiAutomation.notNull()) { foreach (var window in guiAutomation.windows()) { if (window.Name == windowName) { return(window); } } } return(null); }
public static API_GuiAutomation attach(this API_GuiAutomation guiAutomation, string title) { try { guiAutomation.Application = Application.Attach(title); guiAutomation.TargetProcess = guiAutomation.Application.Process; return(guiAutomation); } catch (Exception ex) { ex.log("in attach"); return(null); } }
//window public static API_GuiAutomation button_Click(this API_GuiAutomation guiAutomation, string windowName, string buttonName) { var window = guiAutomation.window(windowName); if (window.notNull()) { var button = window.button(buttonName); if (button.notNull()) { button.mouse().click(); } } return(guiAutomation); }
public static Window window(this API_GuiAutomation guiAutomation, string windowName, int numberOfTries) { for (int i = 0; i < numberOfTries; i++) { var window = guiAutomation.window(windowName); if (window.notNull()) { "after {0} tries, found window with title: {1}".info(i, windowName); return(window); } guiAutomation.sleep(1000, false); } "after {0} tries, cound not find window with title: {1}".info(numberOfTries, windowName); return(null); }
public static List <Window> desktopWindows(this API_GuiAutomation guiAutomation) { for (int i = 0; i < 5; i++) { try { return(WindowFactory.Desktop.DesktopWindows()); } catch (Exception ex) { ex.log("in API_GuiAutomation in desktopWindows"); } } return(null); }
public static List <Window> windows(this API_GuiAutomation guiAutomation) { try { if (guiAutomation.notNull() && guiAutomation.Application.notNull()) { return(guiAutomation.Application.GetWindows()); } } catch (Exception ex) { ex.log(); } return(new List <Window>()); // do a soft landing }
public static Button button(this API_GuiAutomation guiAutomation, string text, int waitCount) { "Trying {0} times to find button '{1}'".info(waitCount, text); for (int i = 0; i < waitCount; i++) { guiAutomation.sleep(2000, true); // wait 2 secs and try again try { var button = guiAutomation.button(text); if (button.notNull()) { return(button); } } catch {} } "Could not find button '{0}'".error(text); return(null); }
public static API_GuiAutomation keyboard_sendText(this API_GuiAutomation guiAutomation, string text) { guiAutomation.keyboard().text(text); return(guiAutomation); }
public static API_GuiAutomation stop(this API_GuiAutomation guiAutomation) { guiAutomation.Application.Kill(); return(guiAutomation); }
public static API_GuiAutomation mouse_RightClick(this API_GuiAutomation guiAutomation) { guiAutomation.mouse().rightClick(); return(guiAutomation); }
public static Keyboard keyboard(this API_GuiAutomation guiAutomation) { return(Keyboard.Instance); }
public static API_GuiAutomation attach(this API_GuiAutomation guiAutomation, Process process) { guiAutomation.Application = Application.Attach(process); return(guiAutomation); }
public static API_GuiAutomation mouse_DoubleClick(this API_GuiAutomation guiAutomation) { guiAutomation.mouse().doubleClick(); return(guiAutomation); }
public static API_GuiAutomation mouse_MoveBy(this API_GuiAutomation guiAutomation, double x, double y) { Mouse.Instance.mouse_MoveBy(x, y, true); return(guiAutomation); }
public static Mouse mouse(this API_GuiAutomation guiAutomation) { return(Mouse.Instance); }
public static bool click_Button_in_Window(this API_GuiAutomation guiAutomation, string windowTitle, string buttonText) { return(guiAutomation.click_Button_in_Window(windowTitle, buttonText, false)); }
public static bool click_Button_in_Window(this API_GuiAutomation guiAutomation, string windowTitle, string buttonText, bool animateMouse) { return(guiAutomation.click_Button_in_Window(windowTitle, buttonText, animateMouse, 5)); }
public static List <Hyperlink> links(this API_GuiAutomation guiAutomation) { return(guiAutomation.firstWindow().links()); }
public static Button link(this API_GuiAutomation guiAutomation, string text) //search on the first window { return(guiAutomation.firstWindow().button(text)); }
public static bool hasLink(this API_GuiAutomation guiAutomation, string text) //search on the first window { return(guiAutomation.link(text).notNull()); }
public static List <Button> buttons(this API_GuiAutomation guiAutomation) { return(guiAutomation.firstWindow().buttons()); }
public static bool click_Button_in_Window(this string buttonText, string windowTitle, bool animateMouse, int timesToTry) { return(API_GuiAutomation.currentProcess() .click_Button_in_Window(windowTitle, buttonText, animateMouse, timesToTry)); }