public API_GuiAutomation launchRdpClient(string ipAddress, string username, string password)
        {
            var terminalServicesClient = Processes.startProcess("mstsc.exe");
            var guiAutomation          = new API_GuiAutomation(terminalServicesClient);
            var window = guiAutomation.window("Remote Desktop Connection");

            window.textBox("Computer:").set_Text(ipAddress);

            if (username.valid())
            {
                window.button("Options ").click();
                this.sleep(1000);
                window.textBox("User name:").set_Text(username);
            }

            window.button("Connect").mouse().click();
            var loginWindow = guiAutomation.window("Windows Security", 3);

            if (password.valid())
            {
                guiAutomation.keyboard_sendText(password);
            }
            loginWindow.button("OK").click();

            return(guiAutomation);
        }
Beispiel #2
0
 public bool install()
 {
     if (this.isInstalled().isFalse())
     {
         "[API_Fiddler] Starting Fiddler installation process".info();
         var fiddlerInstaller = this.installerFile();
         var guiAutomation    = new API_GuiAutomation();
         guiAutomation.launch(fiddlerInstaller);
         var installWindow = guiAutomation.window("Fiddler2 Setup: License Agreement");
         installWindow.button("I Agree").click();
         var installTextBox = installWindow.textBox(@"C:\Program Files\Fiddler2");
         installTextBox.set_Text(this.Install_Dir);
         if (installTextBox.get_Text() == this.Install_Dir)
         {
             installWindow.button("Install").click();
         }
         else
         {
             "[API_Fiddler] in install automation, rrror setting the target directory".error();
         }
         installWindow.button("Close").click();
         "[API_Fiddler] Fiddler installation complete".info();
     }
     if (this.isInstalled())
     {
         "[API_Fiddler] Fiddler is installed in folder:{0}".info(this.Install_Dir);
         return(true);
     }
     "[API_Fiddler] Counld NOT find Fiddler installation in folder:{0}".info(this.Install_Dir);
     return(false);
 }
Beispiel #3
0
 public API_Fiddler start()
 {
     install();
     if (Fiddler_Process.notNull())
     {
         "[API_Fiddler] in start, the Fiddler_Process is already mapped to a running process. Stopping request".error();
         return(this);
     }
     attach();
     if (Fiddler_Process.isNull())                       // means we were NOT able find a running instance and get its process object
     {
         if (Fiddler_Exe.fileExists().isFalse())
         {
             "[API_Fiddler] Could not find Fiddler Exe file at location: {0}".error(Fiddler_Exe);
             return(null);
         }
         Fiddler_Process = Processes.startProcess(Fiddler_Exe);
     }
     Fiddler_GuiAutomation = new API_GuiAutomation(Fiddler_Process);
     if (Fiddler_GuiAutomation.isNull())
     {
         "[API_Fiddler] Could not set Fiddler_GuiAutomation".error();
         return(null);
     }
     Fiddler_Window = Fiddler_GuiAutomation.window(FIDDLER_MAIN_WINDOW_TITLE);
     if (Fiddler_Window.isNull())
     {
         "[API_Fiddler] Could not get Fiddler main window with title: {0}".error(FIDDLER_MAIN_WINDOW_TITLE);
         return(null);
     }
     return(this);
 }
        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);
        }
        //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);
 }
Beispiel #7
0
        public static API_GitHub putty_generateKeys(this API_GitHub gitHub, string keyPassPhrase, string publicKey, string publicKeyForSSH, string privateKey)
        {
            if (publicKey.inValid() || privateKey.inValid() || publicKeyForSSH.inValid())
            {
                "the  publicKey, publicKeyForSSH, privateKey paths needs to be valid".error();
                return(gitHub);
            }
            var puttyGenPath = @"C:\Program Files\TortoiseGit\bin\puttygen.exe";

            if (puttyGenPath.fileExists().isFalse())
            {
                "Error: could not find puttyGen in TortoiseGit folder: {0}".error(puttyGenPath);
                return(gitHub);
            }
            var process        = puttyGenPath.startProcess();
            var puttyGen       = new API_GuiAutomation(process);
            var window         = puttyGen.windows()[0];
            var generateButton = window.button("Generate").click();

            /// lets move the mouse a bit to create some randomness for PuttyGen
            window.mouse();
            generateButton.mouse();
            window.mouse();
            generateButton.mouse();
            window.mouse();
            //once the key is generated we need to put in the passphrase
            if (keyPassPhrase.inValid())
            {
                window.textBox("Key passphrase:").set_Text(keyPassPhrase ?? "");
                window.textBox("Confirm passphrase:").set_Text(keyPassPhrase ?? "");
            }

            //Saving public Key for SSH
            var keyForOpenSSH = window.textBoxes()[0].get_Text();

            keyForOpenSSH.saveAs(publicKeyForSSH);

            //Saving private Key
            window.button("Save private key").mouse().click();
            var warning = puttyGen.window("PuTTYgen Warning");

            if (warning.notNull())
            {
                warning.button("Yes").mouse().click();
            }
            var saveAsWindow = puttyGen.window("Save private key as:");

            saveAsWindow.textBox("File name:").set_Text(privateKey);
            saveAsWindow.button("Save").mouse().click();

            //Saving public Key
            window.button("Save public key").mouse().click();
            warning = puttyGen.window("PuTTYgen Warning");
            if (warning.notNull())
            {
                warning.button("Yes").mouse().click();
            }

            saveAsWindow = puttyGen.window("Save public key as:");
            saveAsWindow.textBox("File name:").set_Text(publicKey);
            saveAsWindow.button("Save").mouse().click();

            process.stop();

            "The keys were saved to {0} and {1}: {0}".info(publicKey, privateKey);

            return(gitHub);
        }