您好我需要从autoit.exe返回一个值(String)到java程序(调用autoit.exe的程序)。所以请帮我回报价值。下面是代码 - 自动脚本,我试图从我正在阅读的组合框中读取值。然后我返回值。
Main()
Func Main()
Local Const $dialogTitle = $CmdLine[1]
Local Const $timeout = 5
Local $OTHERARGS= $CmdLine[1]
Local $windowFound = WinWait($dialogTitle, "", $timeout)
Local $windowHandle
If $windowFound Then
$windowHandle = WinGetHandle("[LAST]")
WinActivate($windowHandle)
Local $sString = ControlGetText("","","[CLASS:Edit;INSTANCE:1]")
ControlClick($windowHandle, "", "[CLASS:Button; TEXT:&Cancel]")
Return $sString
Else
Exit(1)
EndIf
EndFunc
此代码工作正常,因为它返回0作为进程退出值。但是我无法获得返回字符串值。以下是java的代码:
String exePath = "D:\\amit\\Documents\\CancelSave.exe";
exePath = exePath.replace("//", "\\");
Process process = new ProcessBuilder(exePath,""+windowName).start();
// get the input stream of the process and print it
InputStream in = process.getInputStream();
for (int i = 0; i < in.available(); i++) {
System.out.println("" + in.read());//Here it print nothing
}
答案 0 :(得分:1)
ConsoleWrite ( "data" )将字符串写入STDOUT。因此,从AutoIt脚本返回一个值,您应该将值写入STDOUT并退出AutoIt脚本,然后使用流阅读器读取该值。