Machine.windows], [Machine.focusedWindow], or [Instance.windows];
exposes read-only metadata (title, pid), state probes
(isMinimized, isMaximized), named visual-state actions
(minimize, maximize, normal, close), window-relative input, and
accessibility access. On Android a “window” is an application task (a
recents-overview entry).
Constructor
Returns
Window
Properties
number
required
Process ID that owns this window.
string
required
Window title (may be empty).
Methods
backgroundButton()
Window.backgroundMoveMouse] first to choose the location.
Supported on macOS only.
Parameters
Button
required
Direction
required
backgroundClick()
(x, y) in this window without moving the
system cursor or bringing the application to the foreground.
Coordinates are window-frame-relative. Supported on macOS only.
Parameters
number
required
number
required
Button
required
Direction
required
backgroundKey()
Parameters
Key
required
Direction
required
backgroundKeyOther()
Parameters
number
required
Direction
required
backgroundKeyUnicode()
Parameters
string
required
Direction
required
backgroundMoveMouse()
(x, y) are window-frame-relative. The location is retained for
subsequent [Window.backgroundButton] and [Window.backgroundScroll]
calls, and stays anchored to the window frame even if the window is
moved in between.
Supported on macOS only. Throws on other platforms or when macOS
background event delivery is unavailable.
Parameters
number
required
number
required
backgroundRaw()
Parameters
number
required
Direction
required
backgroundScroll()
Window.backgroundMoveMouse] first to choose the location.
Supported on macOS only.
Parameters
number
required
number
required
backgroundText()
Parameters
string
required
boundingBox()
Machine]).
right and bottom are exclusive (Playwright / DOM convention).
Coordinates can be negative when the window sits on a monitor that
is arranged to the left of / above the primary display.
Returns
BoundingBox
button()
Window.moveMouse] — combine
the two for press / drag / release patterns. Takes no coordinate
argument: pair with moveMouse when you need to control where the
press lands.
Parameters
Button
required
Direction
required
click()
(x, y) inside this window and synthesise a
mouse button event. Sugar for moveMouse(x, y); button(...).
Coordinates are window-frame-relative (see [Window.moveMouse]), and
are subject to the same bounds / on-screen validation: an off-frame or
off-screen target throws instead of clicking the wrong location.
Does not focus the window.
Parameters
number
required
number
required
Button
required
Direction
required
close()
focus()
- macOS: raises the window via the accessibility
AXRaiseaction so it becomes the app’s key window, then activates the owning application with default options so that key window surfaces. - Windows:
SetForegroundWindow+BringWindowToTop. Subject to the foreground lock — the call may be downgraded to a taskbar flash if the foreground process didn’t grant permission. - Linux: EWMH
_NET_ACTIVE_WINDOWclient message to the WM.
Returns
boolean
ground()
concept inside this window’s pixels and return its global
desktop coordinates [x, y] in OS-native units (may be negative on
multi-monitor setups; see [Machine]), ready to feed straight
into [Machine.moveMouse] / click helpers on the owning machine.
Sugar for screenshot(true).ground(model, concept) — the cursor is
hidden because it can occlude or distract the model. Restricts the
model’s search to this window’s bounds, which is both faster (fewer
pixels to upload) and more accurate (no risk of grounding onto a
concept that happens to be elsewhere on the screen) than grounding a
full-screen screenshot.
Drop down to [Window.screenshot] + [Screenshot.ground] directly
when you want to keep the cursor visible, reuse the screenshot across
multiple ground calls, or shrink / compress the image before
sending it.
The screenshot includes any portion of the window that’s past the
desktop edge (the capture reads the window’s own backing store, not a
display rectangle). A concept the model locates in that off-screen
region returns coordinates the OS won’t route a click to;
[Window.moveMouse] catches this and errors out instead of clicking
the nearest on-screen point.
Parameters
GroundingModel
required
string
required
Returns
[number, number]
isMaximized()
false. Android: the task is on
screen and occupies it fully.
Platform notes:
- Windows:
IsZoomed && !IsIconic. - macOS: accessibility
AXFullScreen && !AXMinimized. macOS has no native “maximized” concept — [Window.maximize] enters full screen on modern macOS, so this reports that state. A window manually zoomed to fill the screen (Option-click the zoom button) reportsfalse. - Linux: EWMH
_NET_WM_STATEcontains bothMAXIMIZED_HORZandMAXIMIZED_VERT, and notHIDDEN.
Returns
boolean
isMinimized()
- Windows:
IsIconic. - macOS: reads the accessibility
AXMinimizedattribute. - Linux: EWMH
_NET_WM_STATEcontains_NET_WM_STATE_HIDDEN.
Returns
boolean
maximize()
- Windows:
ShowWindow(SW_MAXIMIZE). - macOS: sets
AXFullScreen. A minimized window is un-minimized first. - Linux: EWMH
_NET_WM_STATEadd ofMAXIMIZED_HORZ+MAXIMIZED_VERT, then maps the window if it was iconified.
minimize()
- Windows:
ShowWindow(SW_MINIMIZE). - macOS: sets the accessibility
AXMinimizedattribute. A full-screen window is taken out of full screen first; otherwise the attribute is ignored. - Linux: ICCCM
WM_CHANGE_STATE→IconicState.
moveMouse()
(x, y) are window-frame-relative, in OS-native units (physical
pixels on Windows/Linux, logical points on macOS) — (0, 0) is the
top-left of [Window.boundingBox], which includes the title bar and
other OS chrome.
Two validation passes run before any input is synthesized, and either
failing throws:
(x, y)must lie inside the window frame ([0, width) × [0, height)).- The resulting global point must fall on at least one connected display. Windows dragged partly off-screen can map an in-frame point to a coordinate the OS would silently clamp to a display edge — erroring out is strictly more useful than moving the cursor somewhere unintended and clicking the wrong thing.
Window.focus] (or
[Instance.focus]) first if the click target requires the window
to be active.
On Android there is no real cursor: the point is recorded and the
next [Window.button] press/release becomes a tap or swipe there.
Input is routed to the window’s own pointer: the host’s global
mouse for local windows, the device’s emulated pointer for Android
windows.
Parameters
number
required
number
required
node()
Returns
AccessibilityNode
normal()
- Windows:
ShowWindow(SW_SHOWNORMAL). - macOS: clears
AXMinimizedif needed, then clearsAXFullScreen. - Linux: EWMH
_NET_WM_STATEremove ofMAXIMIZED_HORZ+MAXIMIZED_VERT, then maps the window if it was iconified.
scoredSearch()
overallDescription
(simulang_rs::AXNodeSynthetic::summary_with_context).
Mirrors simulang_rs::Window::scored_search, which resolves the
window’s accessibility root and walks it (on Windows this prebuilds
the cached UIA subtree so the walk costs a single IPC). Returns every
node whose score equals the maximum found and exceeds threshold.
order–TraversalOrder.DepthFirstorTraversalOrder.BreadthFirstmax_nodes– upper bound on nodes visited (uses.take()over the walk)collapse_structural– hoist empty structural wrappers out of the walk before scoringquery– natural-language concept Jaccard-compared against each node’soverallDescriptionthreshold– minimum score to keep a node
AccessibilityNode handles — call action
methods (activate, setValue, …) directly on them, walk children
with .children(), or render a snapshot with .snapshot().
Parameters
TraversalOrder
required
number
required
boolean
required
string
required
number
required
Returns
AccessibilityNode[]
screen()
Window.boundingBox] (the same
heuristic the OS uses to decide a window’s “owning” screen), on
Android the device’s screen.
Locally this throws if the window has no measurable overlap with any
connected display — for example when the window is fully off-screen,
minimised to an off-screen state, or on a virtual desktop with no
attached display. There is no “correct” screen to pick in that case;
callers that prefer a fallback can wrap in try / catch and call
[Machine.mainScreen].
Returns
Screen
screenshot()
hideCursor is ignored — a phone has no cursor).
Parameters
boolean
required
Returns
Screenshot
scroll()
(deltaX, deltaY) ticks at the cursor’s
current location. Positive deltaY scrolls down; positive
deltaX scrolls right. Does not reposition the cursor first —
pair with [Window.moveMouse] if you need scrolling to happen at
a specific point inside the window.
Parameters
number
required
number
required
snapshot()
AXWindow on macOS,
UIA.ControlType.* on Windows), with title and value appended when
non-empty. No refs are assigned — for ref-based interaction use
[AccessibilityTree.snapshot] instead.
Returns
string
