macOS – How Exactly Does Cmd-Shift-4+Space Work?

macos

Cmd ⌘ Shift ⇧ 4 + Space behaves unexpectedly. For example, when I right-click on Chrome, the captured window does not include the right-click UI.

What exactly determines a unit in Cmd ⌘ Shift ⇧ 4 + Space ?

How exactly does Cmd ⌘ Shift ⇧ 4 + Space work?


(Mac v10.12.5 here, though focused on generality.)

Best Answer

WindowServer

The unit being captured is a layer or window as determined by macOS's WindowServer process.

As a developer, this is accessed through CoreGraphic's CGWindowListCreateImage method:

CGImageRef CGWindowListCreateImage(CGRect screenBounds, CGWindowListOption listOption, CGWindowID windowID, CGWindowImageOption imageOption);

This call returns a composite image based on a dynamically generated list of windows.

Screen Captures with Layers

Tools like Acorn, ScreenShot PSD, and Ondesoft ScreenCapture can take screenshots capturing all the individual layers or windows. The resulting capture retains the layering, allowing you to select, hide, or edit windows as desired.