Reputation:
I need to run an external application from within my Java code. I can run the application with Runtime r = Runtime.getRuntime() and then r.exec(...), however, this brings up the GUI of the application. And I still need enter some settings in some fields and press enter. So:
Is there some way to handle a GUI (filling out fields, pressing "return"..etc) from within Java code?
Thanks in advance for any answers,
Anas
Upvotes: 1
Views: 1029
Reputation:
Thanks RichieHindle and Vanya for your comments. AWT Robot class does work with an external softwatre (in this instance, I only need to press an enter. It did that, no problem). But further handling seems quite difficult, since every key stroke (entering a username) needs a java line (unless there is someshort cut that I missed). I will try to automata the process more, or find some work around.
Thank you, this was informative.
Anas
Upvotes: 0
Reputation: 281365
Use the AWT Robot class:
"This class is used to generate native system input events for the purposes of test automation, self-running demos, and other applications where control of the mouse and keyboard is needed."
Upvotes: 3