-4
我有以下AutoIt的代码,我想知道如何迁移/转换到Java有谁知道如何从AutoIT代码更改为Java?
的AutoIt:
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,"[email protected]{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
这是我想转换成Java:
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, "[email protected]{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());
}
}
任何人都可以帮助我吗?
为什么你的代码不工作?请包含您的错误消息。正如所写的,有些人可能会认为你问的是为你编码的服务。 –
那么,错误是什么?发生了什么?还是没有发生? –
嘿家伙,目前没有被执行,所以什么都没有发生,也许我的java代码有问题 – Fer