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
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
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(...)
.
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();
}
}
}