wait_for_change
Watch a screen region, window, or monitor and return when it changes or settles, replacing guessed sleeps with elapsed time, change location, and a final screenshot.
Instructions
Watch part of the screen and return when it changes (mode 'change') or when it has stopped changing (mode 'settle'), instead of guessing a sleep. Reports how long it took, where the screen changed, and the final state as an inline screenshot. regions are in the screenshot's pixels (like find_text and screen_diff); add origin for desktop coordinates.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| keep | No | Keep the final screenshot on disk and return its path (default false: it is only returned inline). | |
| mode | No | 'change' (default) returns as soon as the target differs from when the call started (a dialog opened, a page responded). 'settle' returns once the target has stopped changing for settleSec (a build finished, a page finished loading). | |
| target | Yes | What to watch: 'full' | 'monitor:<index>' | 'window:<title>' (or window:exe=<app.exe> / window:hwnd=<handle>) | 'region:<x>,<y>,<w>,<h>'. | |
| settleSec | No | Mode 'settle': how long the screen must stay still (default 1). | |
| exactTitle | No | For window: targets, match the title exactly (default false). | |
| intervalMs | No | Pause between checks in ms (default 250); each check itself takes ~0.2 s. | |
| timeoutSec | No | Give up after this many seconds (default 30). A timeout is a normal result, not an error. | |
| returnImage | No | Also return a screenshot of the final state inline (default true). | |
| pixelThreshold | No | How different (0-255 mean) a cell of about 32x32 screen pixels must be to count as changed (default 12: catches a changed label or a toast). |