Screenshot of non active window
Solution 1
for i in `xprop -root|grep "_NET_CLIENT_LIST_STACKING(WINDOW): window id" |tr '#' ','|tr ',' '\n'| grep 0x`;do xwininfo -id $i|grep "Window id" ;done
Using the above I was able to get the windows id. and using
xwininfoable to find the label or name or title of the window.
Solution 2
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.
Solution 3
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).
Related videos on Youtube
spendyala
Updated on September 18, 2022Comments
-
spendyala over 1 year
How to take a screen shot of non active window? If I have 2 windows, I want to capture the screenshot of the one which is running in the background.
-
phunehehe almost 11 yearsInteresting, I'm not sure if that's possible.
-
Admin almost 11 yearsI think you should improve your question by making clear what is meant by "non active". Is this window, presumably not the one in focus, totally visible or partly visible or not visible at all because the active window covers part or all of it?
-
-
spendyala almost 11 yearsYes, non active means not having the focus. We can take screenshot of focused one. Can we make the window which is not having focus to be focused using command line. If so how can be do that.
-
spendyala almost 11 yearsI want to do in commandline, to automate the process.
-
Uwe almost 11 yearsI just checked that
import
(from the ImageMagick suite) has a-window id
option. If you know the window identifier that should work, even on the command line. You can get the window identifier usingxwininfo
, but for that you'll have to use the mouse at least once. -
spendyala almost 11 yearsCan I extract for fixed height and width using import along with window id. I am also checking that.
-
spendyala almost 11 years
import -window <window_ID> screenshot.png
-
spendyala almost 11 yearsThis is the last step to automate the process. This is an interesting one for me.
-
erik almost 8 yearsInteresting to know: You get the window id if you do
xwininfo | grep -i 'window id'
and click on the window in question. -
AnonymousLurker almost 6 yearsdoes not work if the window is fully invisible (in another workspace, not the active one)
-
Stefan Reich over 5 yearsFor me, both commands work fine... unless the window is minimized (I'm using Peppermint Linux).
-
Kusalananda almost 4 yearsThis does not actually answer the question. It gets the window's ID, name and/or title, but it never takes a screenshot.
-
ajgringo619 over 3 yearsCan you explain in more detail why this is a solution?
-
thess over 3 yearsWith it kwin dont call "hideinternal" and flag map_state always IsVieable for minimized windows etc github.com/KDE/kwin/blob/…