0

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.

arax
  • 1,831
  • 12
  • 16

1 Answers1

3

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]
cvgmt
  • 72,231
  • 4
  • 75
  • 133