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.

