Hello!
Basically I have a script in Python that grabs the text from an open window using getWindowText() and outputs it to the screen. The python loops so as the text in the window changes, it outputs the changes, so the output of the python will always be up to date with the window text.
I'm trying to access this text in my Java program by executing the python script as a process and reading the text it outputs using a buffered reader.
For some reason this works fine for the first block of text, but will not read any more after this, it wont read any updates to the text as the python outputs it.
Can someone shed some light on this? I'm about to try and use Jython, but I'd really like to know what the problem is here...
try {
Runtime r = Runtime.getRuntime();
Process p = r.exec("cmd /c getText.py");
BufferedReader br = new BufferedReader(
new InputStreamReader(p.getInputStream()));
int line;
while (true) {
line = br.read();
System.out.print((char) line);
}
} catch (Exception e) {
e.printStackTrace();
}