Skip to main content
Obtain via [App.open] or [Machine.foregroundApp].

Constructor

Returns

Instance

Properties

null | number
required
A process ID of the instance, if known. Diagnostic only.On macOS this is the stored launch PID (always set). On Linux it is the launch PID while that process is alive, else the owner of a window attributed to the app by WM_CLASS (a single-instance app handed the launch off to an already-running process). On Windows instances are app-scoped and store no PID; the value is resolved lazily — the owner PID of the app’s first window, else a matching process, else null (e.g. while the app has no window yet). Which process serves a multi-process app is unspecified.

Methods

close()

Request the application to exit gracefully. Returns when the request has been dispatched, not when the process has actually terminated; poll [Self::is_running] if you need to wait.

content()

Text content of the instance’s UI (aria-snapshot style).

Returns

string

disableAccessibility()

Disables the accessibility tree for the instance to save resources. No-op on Android. Creating the accessibility tree is resource-intensive, so many applications disable it by default. After we are done controlling the instance, we should disable the accessibility tree again.

enableAccessibility()

Enables the accessibility tree for the instance. Also works when the application is already running. No-op on Android (uiautomator is always available).

focus()

Brings the instance to the foreground and gives it focus.

Returns

boolean

hide()

Minimizes the instance.

Returns

boolean

isAccessible()

Returns true if the instance has an accessibility tree.

Returns

boolean

isFocused()

Whether the instance has focus.

Returns

boolean

isRunning()

true if the underlying process is still running. Cheap, non-blocking.

Returns

boolean

kill()

Force-terminate immediately. The application gets no chance to save state or run cleanup handlers.

root()

Root accessibility node of this application. On macOS this is the application element (every window plus the app menu bar). On Windows / Linux it is the process accessibility root. On Android it is the current screen root — the instance must be in the foreground.

Returns

AccessibilityNode

scoredSearch()

Search this application’s accessibility tree by concept text, using bag-of-words paired-Jaccard scoring against each node’s overallDescription (simulang_rs::AXNodeSynthetic::summary_with_context). Mirrors simulang_rs::Instance::scored_search with BowJaccard as the scorer and a permissive filter; returns every node whose score equals the maximum found and exceeds threshold.
  • orderTraversalOrder.DepthFirst or TraversalOrder.BreadthFirst
  • max_nodes – upper bound on nodes visited (uses .take() over the walk)
  • collapse_structural – hoist empty structural wrappers out of the walk before scoring
  • query – natural-language concept Jaccard-compared against each node’s overallDescription
  • threshold – minimum score to keep a node
Returned nodes are full 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[]

show()

Shows the instance.

Returns

boolean

windows()

All visible top-level windows belonging to this instance (Android: one window per live task of the app).

Returns

Window[]