java截取电脑全屏
Posted 敏晨
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java截取电脑全屏相关的知识,希望对你有一定的参考价值。
通过java代码截取电脑屏幕全屏代码如下:
1 import java.awt.AWTException; 2 import java.awt.Dimension; 3 import java.awt.Rectangle; 4 import java.awt.Robot; 5 import java.awt.Toolkit; 6 import java.awt.image.BufferedImage; 7 import java.io.File; 8 import java.io.IOException; 9 10 import javax.imageio.ImageIO; 11 12 public class SeleniumDemo { 13 14 public static void main(String args[]) throws IOException, AWTException, InterruptedException { 15 16 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); 17 int screenWidth = (int) screenSize.getWidth(); 18 int screenHeight = (int) screenSize.getHeight(); 19 Robot robot=new Robot(); 20 BufferedImage bi=robot.createScreenCapture(new Rectangle(screenWidth,screenHeight)); 21 ImageIO.write(bi, "jpg", new File("C:\Users\XXX\Desktop\screen\1.jpg")); 22 23 } 24 }
以上是关于java截取电脑全屏的主要内容,如果未能解决你的问题,请参考以下文章