3

Is it possible to take a screen capture of a specific application/exe launched on Windows in Java?

I tried this code but it does not take a capture of the application itself and return a black picture:

try {
    ...
    Robot robot = new Robot();
Rectangle captureSize = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
    BufferedImage bufferedImage = robot.createScreenCapture(captureSize);
    ImageIO.write(bufferedImage,"png",myFile);  
    ...
}    catch(AWTException e) {
    System.err.println("call a doc!");
}

This is why I think that forcing a screenshot linked with the process launched may solve the problem.

Or maybe they are other ways to take a capture of the displayed screen? (if yes could you please show me some working code?)

Arsenic
  • 343
  • 2
  • 13
  • Many applications can take screenshots, e.g. [IrfanView](http://www.irfanview.net/). Is there a reason why you want to do it using a Java program? – f_puras Sep 04 '12 at 09:41
  • 1
    I know about other kind of soft for doing it, I just wanted to implement it by my way on Java – Arsenic Sep 04 '12 at 09:43
  • Are checked this code? http://stackoverflow.com/questions/58305/is-there-a-way-to-take-a-screenshot-using-java-and-save-it-to-some-sort-of-image – Sajith Sep 04 '12 at 09:44
  • 1
    @ Sajith : Of course, please read at least the first 3 lines of my question, you can see which code I tried, quite the same than your link @ f_puras : thanks – Arsenic Sep 04 '12 at 09:46

0 Answers0