Hello, I have the code below which can simply help you for taking the screenshot of the screen which you want.
Code:
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 Screenshot
{
public static void main(String[] args)
{
try
{
Robot robo = new Robot();
BufferedImage bufferedIm=robo.createScreenCapture(new Rectangle(100,100));
ImageIO.write(bufferedIm, "jpg", new File("C:/img.jpg"));
}
catch (AWTException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
Bookmarks