[英]Take foreground application screenshot in Windows using Java without extra edges
[英]Take a screenshot of a specific application on Windows (.exe) in java
是否可以對在Windows中以Java啟動的特定應用程序/ exe進行截屏?
我嘗試了這段代碼,但沒有捕獲應用程序本身並返回黑色圖片:
try {
...
Robot robot = new Robot();
Rectangle captureSize = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
BufferedImage bufferedImage = robot.createScreenCapture(captureSize);
ImageIO.write(bufferedImage,"png",myFile);
...
} catch(AWTException e) {
System.err.println("call a doc!");
}
這就是為什么我認為強制與啟動的過程鏈接的屏幕快照可以解決問題的原因。
還是它們是捕獲顯示屏幕的其他方法? (如果可以,請告訴我一些工作代碼?)
檢查此代碼。
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
BufferedImage capture = new Robot().createScreenCapture(screenRect);
ImageIO.write(capture, "bmp", new File("D:/Newimage.bmp"));
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.