Note that there are some explanatory texts on larger screens.

plurals
  1. POAutomate a legacy Java application from C#
    text
    copied!<p>I have a very old legacy Java application that I'd like to automate from C#. The problem is we don't have the source code of the application and the programmer has long since left the company. I could probably 'decompile' the .jar file but I'm no java programmer either, and I don't think that having access to the source code (without comments) will get me any further.</p> <p>So far i managed to (kinda successfully) automate the application's login dialog, using the following code (I'm polling in a loop because there might be more than one instance of the Java app):</p> <pre><code>while (true) { var processes = Process.GetProcesses().Where(p =&gt; p.MainWindowTitle.Equals("Title of Java Login Window")); foreach (var process in processes) { var handle = process.MainWindowHandle; SetForegroundWindow(handle); await Task.Delay(500); SendKeys.SendWait("the password"); SendKeys.SendWait("{TAB}"); SendKeys.SendWait("the username"); SendKeys.SendWait("{ENTER}"); await Task.Delay(3000); } await Task.Delay(500); } </code></pre> <p>Now the problem is I'm unable to grab the contents of the Java window. For example, there might be a problem with the login, like a wrong user or password. So I wan't to check the Java window for login failure messages.</p> <p>Is there a way to access the actual content (text) of the Java window?</p> <p>Also, all instances of the Java Application share the same PID, because in reality it's just one java.exe process running all the applications. Is there a way to differentiate between the applications? It obviously can't be done using the PID ...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload