Page 1 of 1

HOWTO: Take a screenshot or application shot.

PostPosted: 04 Aug 2008, 10:45
by CronoCloud
Some desktop environments have tools to do so, but minimalistic ones often don't.

First off you may use xwininfo to get information on your application window. You run it in a terminal and then choose the window you want info on. The most important information it provides is the Window id:

Code: Select all
[CronoCloud@mideel ~]$ xwininfo

xwininfo: Please select the window about which you
          would like information by clicking the
          mouse in that window.

xwininfo: Window id: 0x8002f6 "Yellow Dog Linux • Post a new topic - Mozilla Firefox"

  Absolute upper-left X:  0
  Absolute upper-left Y:  14
  Relative upper-left X:  0
  Relative upper-left Y:  15
  Width: 1280
  Height: 751
  Depth: 24
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x20 (installed)
  Bit Gravity State: NorthWestGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +0+14  -0+14  -0-3  +0-3
  -geometry 1280x751+-1+-2


Once you have the window id you can use import from the Imagemagick suite to take the screenshot:

import -window window_id screenshot.jpg

If you want the window decorations you would add -frame to that.

import -window window_id -frame screenshot.jpg (or screenshot.png)

That will capture the shot immediately, but what if you wanted to wait until you had a specific menu or file open? Then you could put a simple sleep command in front to give you time to do that before the screenshot is taken:

sleep number_of_seconds_to_wait; import -window window_id -frame screenshot.jpg

For example if I wanted to capter a shot of the Firefox 3 window after 10 seconds I would do this:

sleep 10; import -window 0x8002f6 -frame screenshot.jpg

Ron Rogers Jr (CronoCloud)

Re: HOWTO: Take a screenshot or application shot.

PostPosted: 06 Aug 2008, 03:38
by tcrroadie
Even easier, you could use a command line tool called scrot. For example to create a screen capture of Firefox, just run in your terminal

Code: Select all
scrot -s -d 8 firefox.png


Then left click on your Firefox window to start the 8 second count down timer and make sure that you do not have any open windows above or below your Firefox window. In 8 seconds a screen capture of your Firefox window will be made.

EDIT by CronoCloud: Thank you tcrroadie, I had not heard of scrot before, apparently it uses the Imlib libraries. It's easily installed via
Code: Select all
 yum install scrot

Re: HOWTO: Take a screenshot or application shot.

PostPosted: 07 Aug 2008, 16:10
by billb
Since this is in the Beginner forum, perhaps you should mention how to take screenshots in Gnome (just hit the Print Screen key) or e17 (use the screenshot app that can be added to the iBar) in your first post. :D