Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

Try doing this:-

try {  
                Robot bot = new Robot();  
                bot.keyPress(KeyEvent.VK_F6);  
                bot.delay(50);  
                bot.keyRelease(KeyEvent.VK_F6);  
            } catch (AWTException ex) {  
                Logger.getLogger(main.class.getName()).log(Level.SEVERE, null, ex);  
            }  
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.