首页 > 代码库 > autoit 处理文件上传弹出框,并在JAVA中调用

autoit 处理文件上传弹出框,并在JAVA中调用

 File file2 = new File(".");
  String command = file2.getCanonicalPath()+"\\resources\\pages\\testdata\\"+"UploadFile.exe";

//exe 文件存放的绝对路径
  Runtime run = Runtime.getRuntime();
 try{
       Process pro=run.exec(command);

//Java调用autoit.exe程序
      BufferedInputStream in=new BufferedInputStream(pro.getInputStream());
      BufferedReader br=new BufferedReader(new InputStreamReader(in));
      String s;
     while((s=br.readLine())!=null){
       System.out.println(s);
      }   }
   catch(IOException e){
   System.out.println(e);
  }

=========================================================

Autoit代码:

WinActivate("Choose file to upload") ControlFocus("Choose file to upload", "", "1148")

Dim $nr

$nr=ClipGet()

Send($nr)

Send("{Enter}")

 

autoit 处理文件上传弹出框,并在JAVA中调用