Win Attach
Win Attach
Section titled “Win Attach”Type: win-attach · Package: Desktop Activities v1.0.8 · Output: ZoanDesktopSession
Connects to a window in Windows and returns a session (ZoanDesktopSession). It is the starting point to interact with a desktop application: once connected, the other activities act on that window.
How it works
Section titled “How it works”It locates the window given by the selector (waiting up to timeout for it to exist) and opens a session. Only the selector’s window nodes (wnd) are used: if it also has control nodes, they are ignored, because what gets connected is the window. When it connects, it brings the window to the front (restoring it if it was minimized).
If the window belongs to a Java application, it also connects the Swing bridge and waits up to 30 s for it to be ready, so the activities in body can see its controls. If that fails, it carries on and leaves a warning in the log.
There are two modes:
- With
body: the activities inside inherit the session automatically (you don’t setsession). Whenbodyends —successfully or with an error— the session is released automatically; the window stays open. In this mode the activity returns no output. - Without
body: it stores the session in an output variable; pass it assessionto the other activities and close it with Win Close.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
selector | selector | — | The window to connect to (wnd node with process, title and/or cls). |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
timeout | number | 30000 | Maximum ms to wait for the window to exist. Empty = the project’s UI timeout or, if not set, 30000. |
Sub-flows
Section titled “Sub-flows”Optional. Activities that run with this window; they inherit the session. If omitted, the session is returned as output.
Output
Section titled “Output”- Without
body: returns aZoanDesktopSession. Pass it assessionto the other desktop activities and close it with Win Close. - With
body: this activity does not return a value.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
Element not found with selector {…}. followed by Diagnostics: … | No visible window matched the selector within timeout. Check that the application is open (or open it first with Open App) and that the title hasn’t changed; use wildcards (Invoice *) for changing titles. |
'selector' is required and must be a valid desktop selector. | The selector is missing or is not a desktop one. Capture it again with UI Discover. |
Example
Section titled “Example”Win Attach selector = (window "Notepad") └─ body: Win Type selector = (text area) text = "Hello world" Win Key Press keys = "ctrl+s"Without body, keeping the session to use it across several steps:
Win Attach selector = (window "Billing") → output: appWin Type session = app selector = (field "Customer") text = customerWin Click session = app selector = (button "Search")Win Close session = app