Print to Image

If you feel like getting your hands dirty, you might be able to use your handy mechanical friend, java.awt.robot, to do this for you.

Note: This is pretty advanced, as it digs into the Java API.

Full Code:


# Capture Test

from java.awt import Robot, Toolkit, Rectangle
from java.io import File
from javax.imageio import ImageIO

robot = Robot()
toolkit = Toolkit.getDefaultToolkit()
dimension = toolkit.getScreenSize()
bufferedImage = robot.createScreenCapture(Rectangle(0, 0, dimension.width, dimension.height))

filepath = system.file.saveFile("screenshot.png", "png", "png file")

if filepath is not None:
	file = File(filepath)
	if ImageIO.write(bufferedImage, "png", file):
		system.gui.messageBox("Image saved.")
	else:
		system.gui.messageBox("Image write failed.")

If you want just a part of your screen, you could take the bufferedImage and manipulate it before saving. (or you could pass a different Rectangle to robot.createScreenCapture())

Hope this helps!