Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I would like to use Mathematica programmatically to take snapshots or screenshots of any open notebook. For example, I would like to get from the notebook created with this command

CreateDocument[{TextCell["Need help", "Section"], 
  TextCell["Can you help?"]}, WindowTitle -> "MyNotebook"]

An image like this entire notebook screenshot

The output can be a file or an image. I use Windows.

share|improve this question
Have you looked at: reference.wolfram.com/language/GUIKit/ref/GUIScreenShot.html? –  user85503 Jul 28 '14 at 16:47
Yes, but that does not provide the solution I need. –  Ariel Sepulveda Jul 28 '14 at 16:51
Related: mathematica.stackexchange.com/q/9331/5 –  The Toad Jul 28 '14 at 16:57

5 Answers 5

It seems there is something you need. Undocumented so who knows.

 FrontEnd`NotebookImage[ EvaluationNotebook[] ]

enter image description here

share|improve this answer
I would love to know how to access those many undocumented features of MMA. Thanks a lot! –  Ariel Sepulveda Mar 24 at 12:46
Nice! Where did you find this? –  Silvia May 30 at 5:26
I think we can use an invisible window as a mask to record a specific area of the screen. –  Silvia May 30 at 5:41
@Silvia I'm just taking a look around in undocumented contexts :) Yes, that's what I've thought! Unfortunately it takes about 0.11 s to take a ss on my laptop so it is not fast enough to make smooth videos. It also does not capture mouse cursor. And the last thing is I had no time to implement this but I'm looking forward to your answer/topic about using this :) –  Kuba May 30 at 6:23
I've written an answer using your function, hope you don't mind :) –  Silvia May 30 at 6:49

This answer, which is a slight modification of my answer to a previous question, takes you most of the way there:

notebookScreenshot[nb_] := 
    Module[{left, top, size, opts = AbsoluteOptions@nb},
        {left, top} = WindowMargins /. opts // Diagonal;
        size = WindowSize /. opts;

        GUIKit`GUIScreenShot[{{left, left + size[[1]]}, {top, top + size[[2]]}}]


It works by finding the explicit pixel locations of the notebook and passing it to GUIScreenShot. You can pass any notebook object to the function and it will work.

The problem here (and I think this is only on OS X) is that the height of the menubar is not reflected in the WindowMargins. I suppose one could get away with offsetting it by 20 pixels (or whatever the right amount is), but I wonder if there's a neater way to get that information.

share|improve this answer
On my system this cuts off the bottom and side of the window. (v10, Windows 7) +1 nevertheless. –  Mr.Wizard Jul 28 '14 at 18:12
This is close to what I need. Other than the offset needed (in OS X and Windows also) there might be another issue with this solution. I think that GUIScreenShot pictures what is visible on the screen and that may not be good if the target window takes all the screen. In this case it would be preferable to create an image of the Notebook object instead of a screenshot of what is displaying in the monitor which will most probably contain the "unwanted-in-screenshot" button used to create the screenshot. –  Ariel Sepulveda Jul 28 '14 at 18:14

This isn't exactly a screenshot but maybe it meets your needs?

doc = CreateDocument[{
  TextCell["Need help", "Section"], 
  TextCell["Can you help?"]}, WindowTitle -> "MyNotebook"];

enter image description here

share|improve this answer
Not enough. I need to have the entire notebook in the image. Thanks. –  Ariel Sepulveda Jul 28 '14 at 17:24
@ArielSepulveda What precisely is missing in this solution? What are you looking to include that isn't? –  Szabolcs Jul 29 '14 at 5:05

One solution is use a snapshot software. I like very much hypersnap , you can test in http://www.hyperionics.com/ with wich you can scroll down an obtain any similar to this


The other option, with Mathematica, to obtain the Out line is...

enter image description here

share|improve this answer
I need to get the entire window including the WindowTitle. –  Ariel Sepulveda Jul 28 '14 at 17:01
@ArielSepulveda ok, for that I use hypersnap, you can see an example at sensa.square7.ch/snap01419.jpg –  Mika Ike Jul 28 '14 at 17:14

OK, based on the feedback provided I have created a solution to the problem. For the benefit of the community I'm posting this solution as an answer to my own question as your feedback, although very useful, missed some key elements.

Note that the variable mySizeAdjustments will most probably need to be adjusted by users depending on the operating system used and other system related parameters. Here is the code:

notebookScreenshot[nb_] := Block[
  {left, top, size, opts, mySizeAdjustments = {18, 75}, windowMargins,
    screenShot, buttonNb = SelectedNotebook[]}
  opts = AbsoluteOptions@nb;
  windowMargins = Replace[WindowMargins, opts];
   {left, top} = Diagonal[windowMargins]
   {left, top} = {0, 0}
  size = mySizeAdjustments + Replace[WindowSize, opts];
  screenShot = GUIKit`GUIScreenShot[{{left, left + size[[1]]}, {top, top + size[[2]]}}];

Note that this solution can take screenshots of notebooks other than the ButtonNotebook or SelectedNotebook from where the command is run. To test the code you can use the following lines:

targetNb = CreateDocument[{TextCell["Need help", "Section"], TextCell["Can you help?"]}, WindowTitle -> "MyNotebook"];

In my case the output that the former lines produce is shown below: enter image description here

share|improve this answer

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.