1、autoit脚本编辑器输入以下代码
;Wait 10 seconds for the Upload windows to appear
;$CmdLine[1]为String.format("s% s% s%",$CmdLine[0],$CmdLine[1],$CmdLine[2])传入的第几个参数
WinWait($CmdLine[1],"",10)
;ControlFocus("title","text",controlID)
ControlFocus($CmdLine[1],"","Edit1")
;Set the file name text on the Edit field
ControlSetText($CmdLine[1],"","Edit1",$CmdLine[2])
Sleep(500)
;Click on the Open button
ControlClick($CmdLine[1],"","Buttonl");
2、autoit编译脚本工具,打开上一步保存的au3文件,转换成exe文件
3、 java代码实现参数化图片上传
String autoitPaths=new File(this.getClass().getClassLoader()
.getResource("autoit/autoit111.exe").getFile())
.getcanonicalPath();
String filePath=new File(this.getClass().getClassLoader()
.getResource("images/stass.png").getFile()).getCanonicalPath();
getElement(By.cssSelector("#staffPic")).click(); //出现windows上传窗口
Thread.sleep(500);
String command =String. format("%s %s %s", autoitPaths, title, filePath);
Runtime.getRuntime().exec(command);