Win Screenshot
Win Screenshot
Section titled “Win Screenshot”Type: win-screenshot · Package: Desktop Activities v1.0.8
Takes a screenshot of the whole window or of a specific element and saves it to an image file. Use it to keep evidence of a result (the receipt the application showed) and to diagnose failures: a screenshot in the catch shows you what the application looked like when something went wrong.
How it works
Section titled “How it works”It captures the screen area of the selector element or —if you leave it out— of the session’s whole window, and saves it in path.
- It captures what is visible on screen in that area: it doesn’t bring the window to the front, so if another window covers it, that one shows up in the image. Use Win Focus first if needed.
- If
pathends in.jpgit saves a JPEG; with any other extension, a PNG. - It creates the destination folder if needed and overwrites the file if it already exists.
- Like every capture, it is explicit: it only happens where you place the activity, never automatically on failure.
To capture the whole desktop without a session or selector, use Take Screenshot.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
path | string | — | Output file path (.png, .jpg). E.g. C:\temp\capture.png. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanDesktopSession | — | Win Attach session. Inside a body it is taken automatically. Required to capture the whole window. |
selector | selector | — | Element to capture. Empty = the session’s whole window. Without a session, the selector must include the window. |
timeout | number | 30000 | Maximum ms to wait for the element (if there is a selector). Empty = the project’s UI timeout or, if not set, 30000. |
Output
Section titled “Output”This activity does not return a value: the image is left in path. If you need the path in a variable, build it in one first and pass it in path.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'session' or 'selector' is required. | There is no session (nor body) and no selector: there’s nothing to capture. |
'path' is required. | The file path is missing. |
Element not found with selector {…}. | See common errors. |
| Windows error while copying the screen | The robot has no interactive desktop (Session 0 or locked session). Run it with a robot session. |
Example
Section titled “Example”Capture the window if something fails, for diagnosis:
Try / Catch errorVariable = error ├─ try: │ Win Click session = app selector = (button "Process") │ Win Wait For session = app selector = (label "Done") state = visible └─ catch: Win Screenshot session = app path = "C:/evidence/error_" + now().ToString("yyyyMMdd_HHmmss") + ".png" Log level = error message = "Processing failed: " + error.MessageKeep as evidence only the receipt the application shows:
Win Screenshot selector = (panel "Receipt") path = pathJoin(evidenceFolder, invoiceNumber + ".png")Related activities
Section titled “Related activities”- Take Screenshot — capture the whole desktop and get the path.
- Try / Catch — take a screenshot while handling an error.
- Win Get Text — read a specific value instead of an image.