第一次下载autoit:https://www.autoitscript.com/site/autoit/
将其添加到 windows 环境变量中的路径,以便可以从命令提示符执行。
示例路径:
C:\Program Files (x86)\AutoIt3
这是一个处理 auto it 脚本的示例方法。
public static void saveFileInternetExplorer() throws Exception {
String pathToAutoItScript = "C:\\save_file_IE11.au3";
String command = "AutoIt3.exe " + pathToAutoItScript;
System.out.println("AutoIt command: " + command );
String output = new CommandLine(command).executeGetOutput();
if (output.contains("ERROR")) {
throw new Exception("AutoIt script error: " + output);
}
System.out.println(output);
}
在 IE 11 中保存文件的 AutoIt 脚本
Sleep(5000)
Local $hIE = WinGetHandle("[Class:IEFrame]")
Local $hCtrl = ControlGetHandle($hIE, "", "[ClassNN:DirectUIHWND1]")
If WinExists($hIE,"") Then
WinActivate($hIE,"")
ControlSend($hIE ,"",$hCtrl,"{F6}") ; Gives focus to Open Button
Sleep(500)
ControlSend($hIE ,"",$hCtrl,"{TAB}") ; Gives focus to Save Button
Sleep(500)
ControlSend($hIE ,"",$hCtrl,"{enter}") ; Submit whatever control has focus
EndIf
Sleep(3000)
点击下载按钮后,运行 autoit3 脚本,这应该会保存文件。
祝你好运!