tags:

views:

227

answers:

2

i am trying to make java application that can get the information from other active window program ...such as information bar or even screenshot of other active window

is JNI the only option in this case?

thanks

A: 

These things are not possible using pure Java.

Your options are using native libraries via JNI / JNI, or calling some external application using Runtime.exec(...).

Stephen C
A: 

Getting information about other items withing the Operating System needs to be done with OS Specific means. You might be able to launch some scripts from inside your program and get some info be reading the output of those scripts ?
Otherwise JNI is the way to go. The whole idea behind Java is to be platform independent, this is accomplished by hiding the OS.

Screenshots are possible

import java.awt.AWTException;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

public class RobotExp {

    public static void main(String[] args) {

        try {

            Robot robot = new Robot();
            // Capture the screen shot of the area of the screen defined by the rectangle
            BufferedImage bi=robot.createScreenCapture(new Rectangle(100,100));
            ImageIO.write(bi, "jpg", new File("C:/imageTest.jpg"));

        } catch (AWTException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Romain Hippeau
i know this but i wanted to get the screenshot of active window of another program on windows ... like Stephen C says this is not possible using pure java library. i think ... ?
stdnoit
You can get to the screen, Java has no knowledge of other windows in the system, for that you need to use JNI as Stephen says.
Romain Hippeau