# How to take a screenshot with java from directX

I'm looking for a way to take a screenshot with a Java application of any running directX game. I use the following code

Robot robot = new Robot();
GraphicsConfiguration config = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
BufferedImage screenshot = robot.createScreenCapture(config.getBounds());
ImageIO.write(screenshot,"png", file);


This one works perfectly anywhere but in directX games. I'm not that familiar with Java and even less with DirectX, I'm just trying to adjust this code. I googled very much, but everything just leads to the same code I already have.

Do you know of another way to take a screenshot of DirectX games?

Thanks.

try {

• What is this supposed to do? What is the purpose of the F6 button? Jun 2 '16 at 19:10