Ubuntu – How to capture a screenshot of a window, and all the windows on top of it

command lineimage processingscreenshotscripts

I'm using screenshots as regression tests for GUI software. Before deploying each new version, a series of automatic tasks is run against the old and the new version, screenshots are generated after each command in both cases, and the results are compared. ImageMagick's import command has been working very well fo that.

Recently I added right click menus. Unfortunately, import -window 'id' doesn't capture these menus.

Which command line tools on Ubuntu can take a screenshot of a window, and all windows on top of it?

That is, which tools can, instead of taking a screenshot of a window corresponding to a window ID, take a screenshot of the entire screen and truncate it to the boundaries a given window?

I haven't been able to get this result in a simple way with any of the tools listed at What is the terminal command to take a screenshot?.

Best Answer

  • Use import with the -screen option, like

    import -screen -window 'id' test.png