0
$\begingroup$

Is there a way to find the handle of a certain window and take a screenshot in Mathematica without having to call external programs? Something that connects with the API for the operating system.

$\endgroup$
3
  • $\begingroup$ does CurrentNotebookImage` give what you need? $\endgroup$ – kglr Sep 30 '20 at 23:35
  • 1
    $\begingroup$ CurrentScreenImage captures full screens or a rectangle from the screen. $\endgroup$ – Jean-Pierre Sep 30 '20 at 23:45
  • $\begingroup$ Is this what you need: 56065? $\endgroup$ – Kuba Oct 1 '20 at 14:05
2
$\begingroup$

Update

Another way! using

Notebooks[]

to list all the windows and then copy one of them to Export!

Export["newCapture.png", copySomethingAbove, ImageResolution -> 400]

See the picture as below!

enter image description here

Original

To control the resolution of image, we can use CreateDocument to creat a new notebook, then write some code and run. SetSelectedNotebook can be used to chose the exact window and then capture it.

nb1 = CreateDocument[Plot[Sin[x], {x, -5, 5}, PlotStyle -> Red]];
nb2 = CreateDocument[Plot[Cos[x], {x, -5, 5}, PlotStyle -> Blue]];
SetSelectedNotebook[nb1];
Export["nb1-picture.png", %, ImageResolution -> 400]
SetSelectedNotebook[nb2]
Export["nb2-picture.png", %, ImageResolution -> 400]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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