Reputation: 99
Hi i need to return a value(String) from the autoit.exe to java program(The program which is calling the autoit.exe). So please help me to return value. Below is the code for - Autoit script where i am trying to read a value from the combo box which i am reading correctly. Then i return the value.
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
This code is working fine as it is returning 0 as a process exit value. However i am not able to get the return string value. Below is the code for 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
}
Upvotes: 1
Views: 2091
Reputation: 5599
ConsoleWrite ( "data" ) writes a string to STDOUT. So instead returning a value from your AutoIt script you should write the value to STDOUT and exit the AutoIt script, then read the value with a stream reader.
Upvotes: 3