How to handle the GUI of external software from Java code

I need to run an external application from my Java code. I can run the application with Runtime r = Runtime.getRuntime () and then r.exec (...), however this calls the application GUI. And I still need to enter some settings in some fields and press enter. So:

Is there a way to handle the GUI (filling in fields, hitting "return", etc.) from Java code?

Thanks in advance for any answers,

Anas

+1


source to share


2 answers


Use AWT robot class :



"This class is used to generate custom system input events for test automation, self-running demos, and other applications that require mouse and keyboard control.

+3


source


Thanks to RichieHindle and Vanya for your comments. The AWT Robot class works with external software (in this case I only need to press the enter button. This did it, no problem). But further processing seems to be quite tricky since every key stroke (username input) needs a java string (unless there is no socket abbreviation I missed). I will try to automate the process more or find a job.

Thanks, that was informative.



Anas

0


source







All Articles