Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to get a screenshot of the entire desktop directly in Mathematica?

I am on Ubuntu running Mathematica 8. For some reason GUIScreenShot[] fails. But something like GUIScreenShot[{{0, 500}, {0, 500}}] works

It is strange that in the reference


is given as an example (last one), with the caption Capture the entire screen:. But when I copy it and paste it in a notebook, it expects a parameter! (I have included the code Needs["GUIKit`"])

I get the error as shown in this image

Screenshot of the image

share|improve this question
I am trying to automate a simple game (!). So grabbing it using an external program, then saving it as a file and importing the file again from within Mathematica is a tedious job (if not realtime). Also I am not sure if I can pipe the output of a program as input to Mathematica (I could not find a way to get it done with Run[] command! - i.e. the piping large output from external program) – my account_ram Aug 11 '12 at 23:16
GUIScreenShot[] works here (Win XP) – Dr. belisarius Aug 11 '12 at 23:34
GUIScreenShot[] doesn't work for me (Arch Linux), it spits this error message on the terminal. Looks like a Linux issue... – Renan Aug 12 '12 at 0:14
It works fine on my win7_x64 and mma8.0.4 (although a syntax indicator). Didn't know this function before. Very helpful! Thanks and +1! – Silvia Aug 12 '12 at 6:52
GUIScreenShot[] works in version 7 under Windows 7. – Mr.Wizard Aug 12 '12 at 7:55

GUIScreenShot[] (without arguments) works perfectly fine on my Mac, although the front end syntax highlighter indicates a missing argument. As a workaround, you can explicitly give it the dimensions of your screen so that all of it is captured. Here's how you can programmatically get your screen size and use it:

GUIScreenShot["FullScreenArea" /. Flatten@SystemInformation["Devices", "ScreenInformation"]]
share|improve this answer
This does not seem to work on Ubuntu .. Can any1 confirm this ... – my account_ram Aug 12 '12 at 0:58
@myaccount_ram I'm having the same problem, but with Arch Linux. – Renan Aug 12 '12 at 4:00
@myaccount_ram It doesn't work on Fedora. – b.gatessucks Aug 12 '12 at 7:34
I got ** Raster data contains 0 values per pixel; 3 or 4 are required with ColorFunction->RGBColor** under Linux 64. – Fred Kline Aug 12 '12 at 20:39
@everyone: The issue seems to be something related to linux and not Mathematica. I would've helped if I could, but I don't have a license to use on my Linux machine. – R. M. Aug 13 '12 at 1:53

A method from Kuba's answer, no GUIKit` is needed. Tested on Mathematica 10.1.

Module[{masknb, img},
       masknb = CreateWindow[{}, WindowSize -> Full, Visible -> False];
       img = MathLink`CallFrontEnd[FrontEnd`NotebookImage[masknb]];

We can even make a fairly fast screen recorder from it:

maskWindow[width_, height_, leftMarg_, topMarg_] :=
        WindowSize -> {width, height},
        WindowMargins -> {{leftMarg, Automatic}, {topMarg, 0}},
        Visible -> False]

screenSnapshot[window_] := 

screenRecord = {};
recordingFlag = True;
        "Click to stop recording:",
            {True -> Framed["Recording"], False -> Framed["Stopped  "]}

        masknb = maskWindow[500, 300, 300, 200];
            screenRecord = Join[screenRecord, {screenSnapshot[masknb]}]
screenRecord = Image /@ screenRecord;

MMA screen recorder

share|improve this answer

Confirming @R.M's answer (WinXP, Mac OSX 10.8)

enter image description here

share|improve this answer
why not a comment? Also, why are you hiding your porn tabs? ;) – R. M. Aug 11 '12 at 23:44
@rm -rf The porn tabs are there ... look again – Dr. belisarius Aug 11 '12 at 23:45
@belisarius Nest[GUIScreenShot[], "", 10] – s0rce Aug 12 '12 at 3:29
@belisarius It's not a Droste effect until it is. – R. M. Aug 12 '12 at 11:57
The Droste Effect: Dynamic[Export["C:\\droste.png", GUIScreenShot[]]; Style[GUIScreenShot[], Magnification -> 1], UpdateInterval -> 3]. When the Dynamic object is not visible, it is not updated (it is sufficient just to reduce the Mathematica window). – Alexey Popkov Aug 12 '12 at 18:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.