Does anyone know how to change from AutoIT code to Java? : <p>I have the following AutoIT code and I'd like to know how to migrate/translate to Java</p>

<p>AutoIT:</p>

<pre><code>   AutoItSetOption("WinTitleMatchMode","20")
   WinWait("Authentication Required")
   While WinExists("Authentication Required")
      Opt("SendKeyDelay", 50)
      $title = WinGetTitle("Authentication Required") ; retrieves whole window title
      $UN=WinGetText($title,"User Name:")
      ControlSend($title,"",$UN,"myemail@gmail.com{TAB}");Sets Username and {TAB}
      $PWD=WinGetText($title,"Password:")
      ControlSend($title,"",$PWD,"mypassword");Sets PWD  and {ENTER}
      ControlSend($title,"",$PWD,"{ENTER}");
      Sleep(2000)
   WEnd
   Exit
</code></pre>

<p>This is what I tried to convert to Java:</p>

<pre><code>public void shouldEnterCredentials() throws Throwable {
        try {
            File file = new File("lib", "jacob-1.18-x64.dll"); //path to the jacob dll
            System.setProperty(LibraryLoader.JACOB_DLL_PATH, file.getAbsolutePath());

            AutoItX x = new AutoItX();
            String title = x.winGetTitle("Authentication Required");
            String un = x.winGetText(title,"User Name:");
            String pwd = x.winGetText(title,"Password:");

            x.autoItSetOption("WinTitleMatchMode","20");
            x.winWait("Authentication Required");
            while (x.winExists("Authentication Required")){
               x.autoItSetOption("OPT_SEND_KEY_DELAY", "50");
               x.controlSend(title,"", un, "myemail@gmail.com{TAB}"); //Sets Username and {TAB}
               x.controlSend(title,"",pwd,"mypassword"); //Sets PWD  and {ENTER}
               x.controlSend(title, "", pwd,"{ENTER}");
               x.sleep(2000);
            }       

        } catch (Exception e) {
            System.out.println("Error: " + e.getStackTrace());
        }
    }
</code></pre>

<p>Can anyone help me, please?</p>
