Constructor
Returns
Screenshot
Properties
[number, number]
required
Returns the screenshot dimensions as
[width, height] in pixels.Methods
base64()
Returns
string
base64DataUrl()
data:image/png;base64,..., data:image/jpeg;base64,...,
data:image/gif;base64,..., or data:image/webp;base64,....
Returns
string
compress()
Parameters
number
required
drawBox()
bounds on the
screenshot. Useful for visualizing bounding boxes returned from grounding,
element / window boundingBox() queries, ground-truth annotations, etc.
bounds is in global desktop coordinates (the same space element /
window boundingBox() and grounding results use); its corners are
converted to image pixels — inverting the capture offset and any
resampling — before drawing, so an element’s boundingBox() can be passed
straight in. It covers [left, right) × [top, bottom) (right / bottom
exclusive). The border is thickness pixels wide, drawn inset, in the
opaque RGB (red, green, blue) color. Pixels that map outside the image
bounds are silently clipped. Throws when thickness is 0 or bounds is
degenerate (right <= left or bottom <= top).
Parameters
BoundingBox
required
number
required
number
required
number
required
number
required
drawDot()
x / y are global desktop coordinates (the same space
Screenshot.ground returns and [Machine.moveMouse] consumes), which are
converted to image pixels — inverting the capture offset and any
resampling — before drawing. So a ground(...) result or an element’s
boundingBox() corner can be passed straight in. radius is the disc
radius in pixels (0 paints a single pixel at the centre).
(red, green, blue) is the fill color; alpha is always 255 (opaque
replacement of the underlying pixel).
Coordinates that map outside the image bounds silently produce no pixel,
so the helper is safe to call even for points that fall outside the
captured region.
Parameters
number
required
number
required
number
required
number
required
number
required
number
required
drawGrid()
width and height.
Parameters
number
required
number
required
ground()
concept on this screenshot using the given grounding model and
return the corresponding global desktop coordinates [x, y] in
OS-native units (may be negative on multi-monitor setups; see
[Machine]). The output can be fed
directly to primitives that expect global screen coordinates.
Equivalent to model.ground(screenshot, concept).
Parameters
GroundingModel
required
string
required
Returns
[number, number]
save()
Parameters
string
required
shrink()
Parameters
number
required
number
required
toMachineCoordinates()
Machine]), so it can be fed straight to
[Machine.moveMouse] without conversion.
Screenshots may represent only part of a display, and the captured
region may have been resampled to a different image size, so this
rescales (x, y) from image space back to the captured region (for
example, when moving the mouse to the same on-screen point).
See ScreenshotCoordinateType for how coord_type affects
interpretation of (x, y).
Parameters
number
required
number
required
ScreenshotCoordinateType
required
Returns
[number, number]
