Robot Task Activities - Image
The Image activity captures a screenshot of a screen, a window or an element and saves it to a file, to the clipboard or to both.
Take Screenshot
Takes a screenshot of all screens, the primary screen, a specific screen, the active or a specific window, or the focused or a specific element, either whole or a rectangle of it.

Properties
The capture target is set in the Screenshot settings property. For a screen capture, the target can be all screens, the primary screen or a specific screen:

The output options are in the Properties pane:
- Screenshot settings: opens the Take screenshot settings window, where the capture target is chosen. See Screenshot Settings
- File path: the full path and file name the image is saved to. The image format follows the extension: ".jpg" or ".jpeg", ".png", ".bmp", ".gif", ".tif" or ".tiff". With no extension, ".jpg" is added and the image is saved as JPEG. With any other extension, the image is saved as JPEG under that name. A missing folder is created
- Save to clipboard: copy the image to the clipboard
- Save to file: save the image to File path. Checked by default
At least one of Save to file and Save to clipboard must be checked, and both can be. With Save to file checked, File path must be a file name, not a folder.
Save to file replaces a file that already exists at File path without asking. Include a variable in the file name so that each run writes a new file.
Screenshot Settings
Click Click to open settings on the activity, or click the ... button of the Screenshot settings property, to open the Take screenshot settings window. The Properties pane that holds the Screenshot settings property:

The Screenshot of list selects the capture target:

- "Screen": an image of one or all screens
- "Window": an image of the active window or of a specific window
- "Element": an image of the focused element or of a specific element
Screen options

- "All": captures all screens into one image
- "Primary": captures the primary screen only
- "Specific": captures the screen chosen in the Screen list, by its display name, such as
\\.\DISPLAY1
Window options

- "Active": captures the active window
- "Specific": captures the window found by Process name and Window title. Both fields are required. Click Click to select window to pick the window and fill in the fields

The activity looks for the specific window three times, about a tenth of a second apart, and fails if the window is not found. It sets focus to the window before the capture.
Element options

- "Focused": captures the element that has focus
- "Specific": captures the element found by the Search element fields: Process name and Window title, which are required, and at least one of Element name, Automation id and Class name. Element text narrows the search. Click Click to select element to pick the element and fill in the fields

The activity fails if the element is not found.
Capturing part of the target
Each target has a size choice. The default, "Full", captures the whole target. "Part" captures a rectangle, set in the Relative position and size of rectangle fields:

- X: the horizontal offset of the rectangle
- Y: the vertical offset of the rectangle
- Width: the width of the rectangle
- Height: the height of the rectangle
For a window or an element, X and Y are measured from the top-left corner of the window or element. For a screen, they are measured from the top-left corner of the screen. All four values are required when "Part" is selected.
Output and errors
- If the image cannot be copied to the clipboard, the error is written to standard error and the sequence continues. The Task fails when the sequence ends
- If the window or element is not found, the activity fails
Tips
- Take a screenshot in the Catch or Finally block of a Try Catch activity. A capture of the screen at the moment of failure is often the fastest way to find out why an unattended Robot Task failed
- Include a variable in File path so that each capture gets a unique name, for example
C:\Logs\{JOB(Active|Name)}_{DATEFORMAT(yyyy-MM-dd_HHmmss)}.jpg - Prefer a window or element capture over a screen capture when only one application matters. The image is smaller and does not depend on the screen layout
- Use "Part" rather than cropping later when the same region is needed every time, such as a status bar or a total field
- To read text from the screen rather than save an image of it, use the OCR Recognize and Get Text activity