Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Take screenshot with Clojure
(import
'(java.awt Rectangle Dimension Robot Toolkit)
'(java.awt.image BufferedImage)
'(java.io 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")))))
(take-screenshot)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment