title: Automate through a remote desktop using Selenium and AutoIt
body: <p>I want to automate certain tasks which needs it to go through <a href="http://en.wikipedia.org/wiki/Remote_Desktop_Services#Remote_Desktop_Connection" rel="nofollow noreferrer">Remote Desktop Connection</a>.</p>
  
  <p>I will share the code which I wrote till now.</p>
  
  <pre><code>public class MainClass
  {
    static WebDriverWait  wait;
    static WebDriver driver;
    public static void main(String args[])
    {
      driver = new HtmlUnitDriver(true);
      driver.get("https://mysite");
      WebElement submit_element=driver.findElement(By.id("Log_On"));
      driver.findElement(By.id("Enter user name")).sendKeys("my_username");
      driver.findElement(By.name("passwd")).sendKeys("my_password");
      submit_element.click();
      driver.findElement(By.id( "folderLink_0")).click();
      driver.findElement(By.id( "folderLink_2")).click();
      driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);
      System.out.println(driver.getPageSource());
      driver.findElement(By.id("idCitrix.M")).click();
      System.out.println(driver.getPageSource());
    }
  }
  </code></pre>
  
  <p>The line of code</p>
  
  <pre><code>`driver.findElement(By.id("idCitrix.M")).click();`
  </code></pre>
  
  <p>opens the remote desktop in a new window.</p>
  
  <p>The line</p>
  
  <pre><code>`System.out.println(driver.getPageSource());`
  is retrieving the same code in both places.
  </code></pre>
  
  <p>I believe this cannot be done solely by Selenium. By browsing through the Internet I learnt it is possible to do this using <a href="http://en.wikipedia.org/wiki/AutoIt" rel="nofollow noreferrer">AutoIt</a>.</p>
  
  <p>How can I do it?</p>