0

Screenshot mit Groovy

Posted by admin on April 22, 2011 in Groovy, Programming |

LogoDas Beispiel funktioniert mit ein paar Try-Catch-Blöcken auch mit Java.

// Snippet for Groovy-Screenshot
import java.awt.*;
import java.awt.image.*;
import javax.imageio.ImageIO;
 
Robot robot =  new Robot();

// Get the size of the default screen
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();

int width = (int)dim.getWidth();
int height = (int)dim.getHeight();

// Creates a BufferedImage
BufferedImage img = robot.createScreenCapture(new Rectangle(0, 0, width, height));

// Write it on the disc
ImageIO.write(img, "png", new File("./screenshot2.png"));

Tags: ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Copyright © 2010-2024 Analysisfreaks.de All rights reserved.
This site is using the Desk Mess Mirrored theme, v2.0.4, from BuyNowShop.com.

Developed by Hardik