Identify the status of a program with java

0

Is there any way to identify the status of a program in Windows by searching the open process with java?

I'm looking for a way to map a specific process from an executable to whether it is in focus on the screen or minimized, thus stopping the process of a macro, pausing the execution of the Robot class when minimized the executable type windows calculator for example.

    
asked by anonymous 26.12.2016 / 19:47

1 answer

2

You can try this:

try {
    String line;
    Process p = Runtime.getRuntime().exec
          (System.getenv("windir") +"\system32\"+"calc.exe");
    BufferedReader input =
            new BufferedReader(new InputStreamReader(p.getInputStream()));
    while ((line = input.readLine()) != null) {
        System.out.println(line); //<-- Parse data here.
    }
    input.close();
} catch (Exception err) {
    err.printStackTrace();
}

Other possibilities:

link

    
26.12.2016 / 20:13