Take Screenshot
Take Screenshot
Section titled “Take Screenshot”Type: take-screenshot · Package: Desktop Activities v1.0.8 · Output: string
Since: v1.0.3
Captures the whole desktop —every monitor or only the primary one— to an image file and returns its path. Use it to see what was on screen when a system error happened: an unexpected dialog, a hung application, a message the robot did not expect.
How it works
Section titled “How it works”It is an explicit activity: it only captures where you place it, usually in the catch of a Try / Catch or in the recovery playbook. The engine never takes screenshots on its own when something fails, because the screen may show sensitive information; you decide which steps are worth capturing and where the images go.
screen = all(default) captures the area of every monitor;primary, only the main monitor.- If
pathends in.jpgor.jpegit saves a JPEG; with any other extension, a PNG. - If
pathis empty, it creates a new file in the robot user’s temp folder:%TEMP%\zoan-screenshots\screenshot-YYYYMMDD-HHmmss-fff.png. - It creates the destination folder if needed and overwrites the file if it already exists.
- Unlike Win Screenshot, it needs no session or selector: it captures whatever is visible, whichever the application.
It needs an interactive desktop (the person’s in attended runs, or the robot session’s in unattended ones). In the Session 0 of Windows services there is nothing to capture.
Required parameters
Section titled “Required parameters”None.
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
path | string | — | Image file (.png or .jpg). Empty = a new .png in the temp folder (zoan-screenshots). |
screen | string | all | What to capture: all (every monitor) · primary (only the main monitor). |
Output
Section titled “Output”Returns a string with the full path of the saved file, ready to attach to a review task, send by email or log together with the error.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
There is no desktop to capture (the robot is not running in an interactive session). | The robot runs without a desktop (Session 0). Run it with a robot session. |
The desktop could not be captured: …. The robot needs an interactive session. | Windows would not let the screen be read (locked session or no desktop). Same as above. |
Since it usually runs inside a catch, make sure a capture failure does not hide the original error: if the machine may end up without a desktop, put it in its own Try / Catch.
Example
Section titled “Example”Save the screen with a unique name when a step fails, and log the path:
Try / Catch errorVariable = error ├─ try: │ Win Click selector = (button "Process") │ Win Wait For selector = (label "Done") state = visible └─ catch: Take Screenshot path = pathJoin(str(Config["CarpetaCapturas"]), "error_" + now().ToString("yyyyMMdd_HHmmss") + ".png") → output: capture Log level = error message = "Processing failed: " + error.Message + ". Screenshot: " + captureOnly the primary monitor, in the temp folder:
Take Screenshot screen = primary → output: captureRelated activities
Section titled “Related activities”- Win Screenshot — capture only one window or control.
- Kill Process — terminate the hung application after capturing.
- Try / Catch — the usual place for the capture.