I have a Java process that runs on a Windows server where I have to kick off a command line exe. I am using
Process p = Runtime.getRuntime().exec(command);
OutputStream stdin = p.getOutputStream();
InputStreamstderr = p.getErrorStream();
InputStream stdout = p.getInputStream();
to run the process and capture standard in/out streams. The problem I am having is one of the exe’s that I have to run will throw a pop-up message box that needs to have “Ok” clicked on before it will finish failing out.
My Java program is running in the background so it does not have a window for the message box to pop up into, meaning when the exe errors the Java program will hang until someone notices it and kills it in Task Manager.
Is there a way to be able to catch or detect these pop-up boxes from Java?
You could be lucky.
You could use JNA to call EnumerateWindows or FindWindow of the Win32 API.
Then search the button via FindWindowEx.
Then “click” it by calling PostMessage and sending a BM_CLICK
You probably want to have a separate watcher thread that does all this, as your programm waits for the process to end or continue.
Sorry my answer is very rough. Dinner has priority.