I wanna take a screenshot of a specific application using the command line. Doing

screencapture -h

Shows option "-o"

-o in window capture mode, do not capture the shadow of the window

Which sounds like it might do what I need, but I am lost on how to actually use this option. Google did not turn up any answers


  • I think you’d need window ID – anki Dec 24 '19 at 8:30
  • How do I get that? Seems kinda tough to get: apple.stackexchange.com/questions/56561/… – user356896 Dec 24 '19 at 8:34
  • Duplicate of apple.stackexchange.com/q/378122/237687 – Solar Mike Dec 24 '19 at 9:45
  • @Solar Mike, IMO This question is not a duplicate of the linked question in your comment as that one is dealing with "specific regions" and specifically the use of the -R<x,y,w,h> capture screen rect option not a "specific window" as in the title of this question, which will require the use of either the -i or -l<windowid> options depending on specifically how it is to be captured. I guess one could say it's somewhat related, but it's not a duplicate. – user3439894 Dec 24 '19 at 17:08

To capture a window using screencapture in Terminal, you have two options:


-i         capture screen interactively, by selection or window
               control key - causes screen shot to go to clipboard
               space key   - toggle between mouse selection and
                             window selection modes
               escape key  - cancels interactive screen shot

You can use the -o option in conjunction with the -i option to not capture the shadow of the window, e.g.: -oi


-l<windowid> capture this windowsid

The -i option appears to be self-explanatory while the -l<windowid> option gives no additional info as with the -i option.

The <windowid>, for some windows can be ascertained by using AppleScript in the following example:

screencapture -l$(osascript -e 'tell app "Safari" to id of window 1') test.png

You can use the -o option in conjunction with the -l option to not capture the shadow of the window, e.g.: -ol

Some applications will not work with this method, however here are some alternatives:

Reference: How do I find the windowid to pass to screencapture -l?
Note: I am not affiliated with these projects.

| improve this answer | |

You must log in to answer this question.