Grab 'impossible' screenshots

Whether you’re remotely trying to help a friend troubleshoot their system or putting together a training document for your office, sometimes you might need to take a picture of your screen. Mac OS X has some excellent screenshot tools available, both built-in and third-party. In case you’re not familiar, or if you just need a brief refresher, here’s a summary:

  • Shift-Command-3: This key combo lets you take a screenshot of everything on any attached displays. Add the Control key to force the image to go to the clipboard instead of to a file on your desktop.
  • Shift-Command-4: This key combo makes a bulls-eye cursor appear. Drag the cursor over any part of your screen to take a screenshot of that region. Hit the Space Bar instead of dragging, and a small camera icon appears. It lets you take pictures of any particular window. As above, add the Control key to force the image to the clipboard.
  • Grab: You’ll find this program in your Applications/Utilities folder, and it has one trick up its sleeve that the other methods don’t—it can take a timed screenshot. Using the timer (Capture: Timed Screen), you can switch to a given program and then have the screen captured automatically. This can be especially useful for programs (such as games) that sometimes disable the built-in keyboard shortcuts.
  • Third party tools: There are a number of third-party programs, as seen on MacUpdate, that will let you take a picture of your screen. I personally use Snapz Pro X to capture screenshots for nearly all of my magazine and Web site articles.

However, none of these tools will help you get certain screenshots, such as this one:

That’s a shot of the login window (in Fast User Switching mode) and a seemingly impossible picture to take. So how’d I do it? The answer is simple, though it does require a second Mac with the ability to access the first Mac over a network.

OS X includes a nice command-line screen capture utility named, simply enough, screencapture. While there’s not a ton of documentation on this program, man screencapture will give you the basic options. Once you’ve used ssh to connect to the Mac whose screen you wish to capture, you need to execute the screencapture command with root privileges. You can also specify some of the command line arguments, as shown in the man page. For instance, here’s how I captured the login window:

  1. First, I had to get the login window on-screen. To do that, I just chose Login Window from the Fast User Switching menu in the menubar. If you haven’t enabled Fast User Switching yet, you’ll have to do so first—it’s in the Login Options section of the Accounts System Preferences panel.
  2. On the second Mac, I opened Terminal (in Applications: Utilities) and used the command ssh to connect to the first. (See the No Files Left Behind article for more detailed info on using ssh to remotely access another Mac.)
  3. On the second Mac, I then issued these commands:

    	$ cd ~/Desktop
    	$ sudo screencapture -ttiff loginwindow.tiff

    The first line just switches me to the Desktop folder of the user that I logged into via ssh. The second line actually takes the screenshot; I’ve used -ttiff to set the type to TIFF ( -t is the ‘set type’ option, and tiff is the type, with no added spaces!), and then specified the name for the file. If you don’t want to hear the camera-clicking sound on the remote Mac, use the -x option.

That’s really all there is to it—other than realizing that the picture you just took is saved on the second Mac, not the target one. To get your picture over to the source Mac, which is probably where you want it, you can use scp, a secure copy program. After you disconnect from the remote Mac, just use something like this to copy the screenshot across:

scp user@remote_mac_address:/path/to/screenshot /local/path/to/save

For example, in my case, I used this command:

scp robg@ ~/Desktop/loginwindow.tiff

You might think this trick is only useful for grabbing login window screenshots, but that’s not the case. It could also be used in a game that locks out the keyboard shortcuts—start the game, ssh in from another Mac, and then grab the screenshot when you reach the spot in the game that you’d like to capture. Another possibility is for checking on a remote Mac that you have running some large task—a backup or a huge download, for instance. Yes, there are GUI ways of connecting and watching the screen, but you might find it faster to use ssh to connect, grab a screenshot, and then copy it back with scp to see exactly where the Mac is at in the process.

To comment on this article and other Macworld content, visit our Facebook page or our Twitter feed.
Shop Tech Products at Amazon
Notice to our Readers
We're now using social media to take your comments and feedback. Learn more about this here.