Jump to content

Recommended Posts

Posted (edited)

I wrote some scripts, and had compiled them to .exe files. And I want to call them in a java method, but how can I get the return value of the .exe file after it's executed. One way I think is to use the shared clipboard: .exe process pastes the return value to the clipboard, and the java process gets the value from clipboard. What I want to know is whether or not there exists other ways to complete it?

Thank you!

Good night!

Edited by mik
Posted

I wrote some scripts, and had compiled them to .exe files. And I want to call them in a java method, but how can I get the return value of the .exe file after it's executed. One way I think is to use the shared clipboard: .exe process pastes the return value to the clipboard, and the java process gets the value from clipboard. What I want to know is whether or not there exists other ways to complete it?

Thank you!

Good night!

I think this is more of a generic exit code question meant for a Java forum, as it isn't AutoIt specific.

Posted (edited)

Thank you very much for your answer:-).

Maybe I haven't express my question clearly. I just want to know the communication way between a java method and a .exe file. Exactly speaking, I want to use autoit to develop some scripts, for example, I use OpenFile($fileName,$filePath) to open the specified file, and I want the caller, java method, to know whether the file is opened successfully. That's to say, the .au3 or .exe file should tell something to the caller, how can I realize it? and I have realized it by using the system clipboard, and I want to know if there are other better ways:-)

Thank you!

Edited by mik
Posted

That's to say, the .au3 or .exe file should tell something to the caller, how can I realize it?

I'm very stupid when it comes to this sort of thing, but how about writing the answer to a file, and let your Java app read the file?

For example, if a file is successfully opened, then AutoIt creates a file named "temp.txt" with "1" in it, but if the file doesn't open successfully, AutoIt creates a file named "temp.txt" with "0" in it. Java then just reads the file. It's like a clipboard... kinda... only the clipboard is an actual file.

Posted

It depends how Java will handle the return codes of course, but when I call AutoIt exes from other AutoIt exes I always pass a return code using:

Exit (return code)oÝ÷ ÙèºÚ"µÍY  ÌÍÜÝXØÙÜÈHH[Q^]
H
B[ÙBQ^]

B[Y

I can then add a simple case statement into the parent exe to interpret the returned code.

If you need something more verbose then I'm with Leuce - writing to a log file and then interpreting the results in another (java) app.

Posted

It depends how Java will handle the return codes of course, but when I call AutoIt exes from other AutoIt exes I always pass a return code using:

Exit (return code)oÝ÷ ÙèºÚ"µÍY  ÌÍÜÝXØÙÜÈHH[Q^]
H
B[ÙBQ^]

B[Y

I can then add a simple case statement into the parent exe to interpret the returned code.

If you need something more verbose then I'm with Leuce - writing to a log file and then interpreting the results in another (java) app.

Thank you all! I haven't come here several days. The operation of IO, via shard file, is rather slow, I think. But it seems no other better solution.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...