[java]代码库
Read this article for more details.importjava.awt.Dimension;import java.awt.Rectangle; importjava.awt.Robot; importjava.awt.Toolkit; importjava.awt.image.BufferedImage; importjavax.imageio.ImageIO; importjava.io.File; ... public voidcaptureScreen(String fileName) throwsException DimensionscreenSize =Toolkit.getDefaultToolkit().getScreenSize();RectanglescreenRectangle = new Rectangle(screenSize); Robot robot =newRobot(); BufferedImage image=robot.createScreenCapture(screenRectangle);ImageIO.write(image,"png", new File(fileName)); ...
import java.awt.Dimension;importjava.awt.Rectangle;importjava.awt.Robot;importjava.awt.Toolkit;importjava.awt.image.BufferedImage;importjavax.imageio.ImageIO;importjava.io.File;
...
public void captureScreen(String fileName) throws Exception
Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();RectanglescreenRectangle= new Rectangle(screenSize);Robot robot = newRobot();BufferedImageimage=robot.createScreenCapture(screenRectangle);ImageIO.write(image,"png",new File(fileName));
...