

Win32gui.EnumWindows(_windowEnumerationHandler, topWindows) #enumerate all open windows, return topWindows

#The text that the wanted window string begins with, so we can find it I can't remember enough to document my code line by line, but I think from the comments it should be quite straightforward. Though it is probably not the most elegant or fastest solution, it worked and I was able to read the window text output into my Java application perfectly.

Nevertheless, I managed to hack together workable code to find a specific open window based on the Title bar text, and grab text from that window. Now at least it does seem to have gotten better, though probably it's easier to find now that I know what to search for. However, from what I remember it was the Python that proved exceptionally difficult, mainly due to terrible documentation, and from some Googling I can see I'm not the only one to have found this problem. I achieved it by simply using Runtime and Process objects.įinal String pythonDir = "cmd /c pythonFile.py" īufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()), 5000) And although this could probably better be achieved in a different language, I thought that integrating Python output into a Java application would be fairly trivial. I had been writing a Java program which required text from the output of a native Windows application. I wrote it to perform the simple function of getting text from an open window in XP, though I assume it would work for other Windows versions. which I was quite pleased about since I thought it had been lost. I just discovered this old piece of code while digging through ancient e-mails.
