Skip to content

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.

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 set session). When body ends —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 as session to the other activities and close it with Win Close.
ParameterTypeDefaultDescription
selectorselector—The window to connect to (wnd node with process, title and/or cls).
ParameterTypeDefaultDescription
timeoutnumber30000Maximum ms to wait for the window to exist. Empty = the project’s UI timeout or, if not set, 30000.

Optional. Activities that run with this window; they inherit the session. If omitted, the session is returned as output.

  • Without body: returns a ZoanDesktopSession. Pass it as session to the other desktop activities and close it with Win Close.
  • With body: this activity does not return a value.
MessageCause 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.
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: app
Win Type session = app selector = (field "Customer") text = customer
Win Click session = app selector = (button "Search")
Win Close session = app
  • Open App — launch the application before connecting.
  • Win Close — close the window and release the session.
  • Win Focus — bring the window to the front.