Screenshot of non active window

To elaborate a bit on previous answers and comments, the ability to capture a screenshot of a non active window (as in fully or partially hidden) seems to depend on the window manager.

Using the following (already given) command :

import -window <windowid> image.png

or

xwd -id <windowid> | convert xwd:- image.png

(the - of convert is for using standard input from the pipe, xwd: tells the format of the input) one seems to be able under Enlightenment (e17, tested with Fedora 19) to capture a screenshot of :

  • fully or partially hidden windows ;
  • minimized windows ;
  • windows on other workspaces.

I checked with Openbox (same configuration) and KDE (with an old Scientific Linux 4.8 and latest version of ImageMagick (yes, incredibly it compiled…)) and in both cases screenshots show only what is on top of the display layers — that is, only what is already visible on screen.

The point is that the import command checks for the map_state field returned by XGetWindowAttributes to be IsViewable, and if not it returns an error. One can check map_state e.g. using :

xwininfo -id <windowid> | grep 'Map State'

It seems to be always IsViewable under e17, while it's IsUnMapped under openbox and KDE as soon as the window is minimized or whatever.

Not sure though why the screenshot is always clean with e17 while it's mixed with other windows when the window is partially recovered with other WMs, but obviously it also has to do with the way the WM handles the display.

Anyway, clearly it's a matter of WM. It would be nice to have a list of WMs able vs unable to do screenshots of hidden windows — I'm not doing it.


What do you mean by "non active"? "Not having the focus" or "hidden by some other window"? In the first case, gimp will do it without any problems (File -> Create -> Screenshot). In the second case, it's more difficult (if it's possible at all).