---
title: "Capture a macOS guide step"
description: "@exact/screen-capture saves a still of the window under the pointer, a display or a region on macOS, after the person grants screen recording."
modificationDate: "2026-11-24"
---

> ## Documentation index
> Fetch the complete documentation index at: https://exact.expo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Capture a macOS guide step

<AgentInstructions>

## Submitting feedback

From the app's directory, read `bun exact.mjs feedback status`. Under `never`, keep no note.
Respect `EXACT_FEEDBACK=0` and do not change the policy.

Otherwise record specific, actionable feedback with:
`bun exact.mjs feedback note "Exact docs: https://exact.expo.dev/recipes/screen-capture: <what was wrong or missing>"`

The note goes to Expo only as that status allows. Include no secrets or personal data.

</AgentInstructions>

Declare `device.screen-recording shot.purpose` and `fs.write app:/tmp`.
Localize the usage string. Drawing a file also needs `fs.read app:/tmp`.
On macOS, call `requestScreenRecording()` from foreground setup if
`screenRecordingStatus()` reports `prompt`. Captures use the existing grant.

```prompt Capture a still of every display
Make the Exact app in this folder capture a still of every display to files, before it shows its window. Use https://github.com/expo/exact/blob/main/docs/recipes/screen-capture.md as the source for each step. The Exact checkout has the same page at docs/recipes/screen-capture.md.

1. If this folder is not an Exact app (it has no exact.mjs and app.contract), stop and tell me.
2. Real capture is on macOS and Windows only: the web, Linux and mobile hosts have none. If I did not say what starts a capture, what the app does with the stills, and the usage sentence macOS shows, propose them and ask me before you write code.
3. Install the package: `bun exact.mjs add @exact/screen-capture`. Declare the grants `device.screen-recording shot.purpose` and `fs.write app:/tmp`, and `fs.read app:/tmp` to read or draw the files. `shot.purpose` is a localized usage string.
4. In app.ts, ask for permission once, from the foreground setup UI: when `screenRecordingStatus()` reads `prompt`, call `requestScreenRecording()`. Never ask from the shortcut handler: capture checks permission without prompting.
5. Call `captureScreens` in the shortcut handler, before the app shows the overlay. Set the hidden window's frame first: with no window, `clientRect` is null. Draw each returned `path` at its display's `clientRect` with an image. A canvas on macOS or the web cannot draw an app file.
6. Every call creates new files: remove them when the app releases that capture.
7. Under the agent, capture writes a colored card for each display: drive it. The drive needs a scratch store (`--storage <name>`). On macOS, `prefer permission.screen-recording granted` bypasses the substitute's permission ticket. `prefer extension screen-capture.screens=[…]` supplies viewport rectangles in the drive or in app.test.contract. Add a test that ends on the setup screen.
8. Follow the platform checks in docs/start-here.md (`bun exact.mjs docs platform checks`) for the targets in the app's AGENTS.md and app.json until they pass. Read the reports, including counted findings; a zero exit code alone does not mean clean. Fix the app, not the test. If a finding stays after three rounds of fixes, or the app had it before you changed anything, record it (step 9) and report it; do not keep trying.
9. When a doc was wrong or missing, or a step needed a workaround, read `bun exact.mjs feedback status`. Under `never`, keep no note. Otherwise record it: `bun exact.mjs feedback note "<what happened>"`, which goes to Expo only as that status says. Do not change the policy; tell me how many notes you kept.
10. Tell me the grants you declared, what the drive, the tests and the checks reported, and what I must still do by hand: allow Screen Recording on macOS and look at a real capture. `--bind screen-capture` uses the OS and requires a person present for a macOS drive.
```

```ts
import { captureScreens, getWindowAtPoint, getFrontmostWindow } from '@exact/screen-capture';
import { getPointerPosition, getScreenDetails } from '@exact/window-management';

const directory = 'app:/tmp/steps';
const { screenX: x, screenY: y } = await getPointerPosition();
const window = await getWindowAtPoint({ x, y });
const { captures: [step] } = await captureScreens({ directory, window: window.handle, cursor: 'always' });
const frame = step.frame!;
const imageX = (x - frame.x) * step.width / frame.width;
const imageY = (y - frame.y) * step.height / frame.height;

const front = await getFrontmostWindow();
const { currentScreen: screen } = await getScreenDetails();
await captureScreens({ directory, screen });
await captureScreens({ directory, screen, rect: { x: 10, y: 20, width: 160, height: 90 } });
```

Pointer and display-list reads need `device.window-management`. Window
lookups need only the recording grant. Each returns a session handle,
title, desktop frame and owning app. Capture includes the app's own
windows. A covered window yields its own pixels. The default cursor is
`never`. Window frames and pointer positions use desktop CSS pixels.
A display region starts at its top left. Subtract the display's `left`
and `top` from a pointer position to place a region there.

For a freeze overlay, set the hidden window's frame and call
`captureScreens({ directory })` before showing it. Each entry gives
`{path, width, height, type, screen}`, ordered by display left then top.
The image dimensions are physical pixels. Draw it at `screen.clientRect`
in window CSS pixels (null without a window). Each call writes fresh
files. Remove them after use.

An agent drive needs `--storage <name>`. It uses the display-list fixture
or `prefer extension screen-capture.screens=[…]` to include a
`clientRect`. Its window covers the primary display and its pointer sits
at the centre. On macOS, `prefer permission.screen-recording granted`
grants the fixture ticket. `--bind screen-capture` uses the OS and
requires a person present. Web and Linux support fixture captures only. Windows takes all-display stills.
Its native window lookups and explicit selectors or cursor settings return
`NotSupportedError`. No Windows executable was run for this change.

For encoding, image limits, errors and platform differences, see the
[package README](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/packages/screen-capture/README.md) and
[reference](https://exact.expo.dev/reference/developer/generate-typescript-data-source-types.md#still-desktop-capture-exactscreen-capture).
