Documentation
¶
Index ¶
- func Capture(ctx context.Context, req CaptureRequest) (contract.ScreenshotResult, error)
- func CaptureRGBA(ctx context.Context, region contract.Bounds) (*image.RGBA, contract.Bounds, error)
- func Cursor(ctx context.Context) (*contract.Point, error)
- func Info(ctx context.Context) (contract.ScreenInfo, error)
- func LogicalCoordsEnabled() bool
- func PrimaryScale(ctx context.Context) float64
- func ResolveCaptureRegionDetailed(ctx context.Context, ref contract.RegionRef) (contract.ResolveResult, error)
- func SetLogicalCoords(enabled bool)
- type CaptureRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Capture ¶
func Capture(ctx context.Context, req CaptureRequest) (contract.ScreenshotResult, error)
func CaptureRGBA ¶
CaptureRGBA grabs the requested screen region into an in-memory RGBA image without writing a file. Used by image-finding primitives that need pixel data, not an encoded screenshot. The returned bounds are the actual capture rectangle in screen coordinates (after clamping).
Accepts a screen-space contract.Bounds directly — callers that have a coord-space-aware contract.RegionRef MUST resolve it via ResolveCaptureRegion before calling this function so the cache key and downstream find_* coord math see consistent screen coordinates.
func LogicalCoordsEnabled ¶
func LogicalCoordsEnabled() bool
LogicalCoordsEnabled reports the current state of the toggle so sibling packages (input) can decide whether to apply the translation. Returns false by default.
func PrimaryScale ¶
PrimaryScale returns the RandR-derived scale of the primary monitor, or 1.0 when no primary is reported. Best-effort — callers should treat any failure as scale=1.0. Used by the experimental --logical-coords translation.
func ResolveCaptureRegionDetailed ¶ added in v0.3.4
func ResolveCaptureRegionDetailed(ctx context.Context, ref contract.RegionRef) (contract.ResolveResult, error)
ResolveCaptureRegionDetailed turns a coord-space-aware RegionRef into a contract.ResolveResult carrying the absolute screen-space Bounds suitable for XGetImage along with optional clamp metadata. Used by Capture and by external callers (pipeline.runFind*, wait.WaitForPixelChange, wait.WaitForText) that need to translate a window-space or monitor-space region into screen coordinates before capturing, and that surface region_clamped / original_region / clamped_region in their action responses.
Screen-space (or empty) RegionRefs pass through unchanged (the physical-screen clamp happens in Capture / CaptureRGBA, not here). Window/window_frame regions require the window list (collected via window.List); monitor regions require the monitor list (collected via Info). Returns the validation/precondition errors emitted by contract.ResolveRegionDetailed verbatim. Unknown spaces drop through to contract.ResolveRegionDetailed so the canonical INVALID_COORDINATE_SPACE error is consistent.
func SetLogicalCoords ¶
func SetLogicalCoords(enabled bool)
SetLogicalCoords sets the process-wide logical-coords toggle. Called once from the CLI/MCP bootstrap after the effective config is loaded. Safe to call concurrently before any capture/input operation runs.
Types ¶
type CaptureRequest ¶
type CaptureRequest struct {
Out string `json:"out,omitempty" jsonschema:"output image path; defaults to a temp file"`
Region contract.RegionRef `` /* 232-byte string literal not displayed */
MaxEdge int `json:"max_edge,omitempty" jsonschema:"downscale output so the longest edge is at most this value; 0 disables"`
Zoom bool `json:"zoom,omitempty" jsonschema:"capture a square crop centered on zoom_x,zoom_y"`
ZoomX int `json:"zoom_x,omitempty"`
ZoomY int `json:"zoom_y,omitempty"`
ZoomSize int `json:"zoom_size,omitempty"`
Format string `json:"format,omitempty" jsonschema:"png or jpeg; defaults to png"`
Cursor bool `json:"cursor,omitempty" jsonschema:"overlay the current cursor when XFixes is available"`
JPEGQuality int `json:"jpeg_quality,omitempty" jsonschema:"JPEG quality from 1 to 100; defaults to 85"`
}
CaptureRequest is the wire shape for the screenshot/capture verb. Region accepts both the v0.1/v0.2 bare-bounds shape (`{x,y,width,height}`) AND the task-12 extended shape (`{x,y,width,height,space:"window"|"window_frame"|"monitor",target?,monitor_index?}`). Both unmarshal into RegionRef; bare-bounds payloads resolve as screen-space without translation, preserving v0.1 wire compatibility.