I've created a small application that allows the user to capture the screenshot and save the image at a user defined location. It also allows the user to capture the screenshot of the active window as well.

The issue is with the active window. I have learnt that Java does not provide a method to get the screenshot of the active window. So, I googled and found that developers have been using the Alt+PrntScrn to get the screenshot and get the image from the clipboard.

The code for this is:

                  RenderedImage image = (RenderedImage)getClipboard();

Now what happens is that when the Alt key is pressed by the robot class, the focus goes on the toolbar of the application of which the user wants to get the screenshot and the screenshot is taken of the toolbar and not that of the window that the user has focus on.

Please advise on how to solve this problem.

Can u send me the entire code format so that i can learn this.is it execute in command prompt

The application runs from the System Tray.

What else code do you need

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.