Simple as the title states: Can you use only Java commands to take a screenshot and save it? Or, do I need to use an OS specific program to take the screenshot and then grab it off the clipboard?
From stackoverflow
jjnguy
-
http://schmidt.devlib.org/java/save-screenshot.html
jjnguy : The reason I didn't accept your answer was because it was someone elses code.From John Millikin -
Believe it or not, you can actually use
java.awt.Robot
to "create an image containing pixels read from the screen." You can then write that image to a file on disk.I just tried it, and the whole thing ends up like:
Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()); BufferedImage capture = new Robot().createScreenCapture(screenRect); ImageIO.write(capture, "bmp", new File(args[0]));
NOTE: This will only capture the primary monitor. See GraphicsConfiguration for multi-monitor support.
Michael Neale : Wow - who would have thought. That is very very cool.Free Wildebeest : I'd never come across java.awt.Robot. That's one impressive and useful class.Flash84x : I wonder if this is what screen sharing applications like Elluminate (http://www.elluminate.com/) use.From David Citron
0 comments:
Post a Comment