Skip to content

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.

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 path ends in .jpg or .jpeg it saves a JPEG; with any other extension, a PNG.
  • If path is 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.

None.

ParameterTypeDefaultDescription
pathstring—Image file (.png or .jpg). Empty = a new .png in the temp folder (zoan-screenshots).
screenstringallWhat to capture: all (every monitor) · primary (only the main monitor).

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.

MessageCause 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.

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: " + capture

Only the primary monitor, in the temp folder:

Take Screenshot screen = primary → output: capture