Win Focus
Win Focus
Section titled “Win Focus”Type: win-focus · Package: Desktop Activities v1.0.8
Activates a window and brings it to the foreground (in front of the others). Useful when several applications are open and you need to make sure the keyboard and mouse go to the right window.
How it works
Section titled “How it works”It locates the element by its selector —the window, or any control inside it— and activates the window that contains it: restores it if minimized, brings it to the front and waits up to timeout for Windows to confirm it is in the foreground. If that doesn’t happen, it fails.
The same timeout is used to find the element and to wait for the foreground.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
selector | selector | — | The window to focus (or a control inside it). |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanDesktopSession | — | Win Attach session. Inside a body it is taken automatically; without a session, the selector must include the window. |
timeout | int | 15000 | Maximum ms to wait for the window to reach the front (and to find the element). Empty = the project’s UI timeout; if not set, 15000 for the foreground and 30000 for the search. |
Output
Section titled “Output”This activity does not return a value.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
The window could not be activated within … ms. | Windows would not bring the window to the front: a modal dialog from another application, the window runs as administrator and the robot doesn’t, or the session is locked. Check the machine with the robot’s account. |
Element not found with selector {…}. | See common errors. |
Example
Section titled “Example”Bring the application to the front before sending it a global keyboard shortcut:
Win Focus selector = (window "ERP")Win Key Press keys = "f5"Related activities
Section titled “Related activities”- Win Attach — connect to the window.
- Win Key Press — send keys to the active window.