As bbum noted in the comments to the article regarding screenshots from the command line, there are some new hidden features in the system's screenshot program.
Press space after hitting shift-command-4 (region capture) and you'll get a camera icon and (at least on my machine) the underlying window highlighted in yellow. Move the camera over another window and the yellow highlight shifts to that window. Click the mouse and you capture the highlighted window.
Additionally, holding control (while using either shift-command-3 or shift-command-4) will result in the image being saved to the clipboard instead of to a file.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20020825105837562