Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Take screenshot with Clojure
'(java.awt Rectangle Dimension Robot Toolkit)
'(java.awt.image BufferedImage)
'( File IOException)
'(javax.imageio ImageIO))
(defn take-screenshot []
(let [screen (.getScreenSize (Toolkit/getDefaultToolkit))
rt (new Robot)
img (.createScreenCapture rt (new Rectangle (int (.getWidth screen)) (int (.getHeight screen))))]
(ImageIO/write img "jpg" (new File (str (System/currentTimeMillis) ".jpg")))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment