Skip to content

OCR Recognize Screen Region

Type: ocr-recognize-region  ·  Package: OCR Activities v1.2.5  ·  Output: string

Captures a rectangular area of the screen and recognizes the text it contains. Useful to read data from an application that does not expose its text in an accessible way (an image viewer, a custom control, drawn content) when Desktop selectors can’t reach it.

Captures the region defined by x, y (top-left corner) and width, height (size), in screen pixels, and runs it through OCR. It requires an interactive desktop session: it captures what is visible at that moment, so the window must be in front with no other windows over it.

  • Coordinates are counted from the top-left corner of the primary screen; with several monitors, screens to the left of or above the primary one have negative coordinates.
  • This activity has no preprocessing. If the capture comes out with errors, save an image with Win Screenshot and read it with OCR Recognize File and preprocess = "auto".
ParameterTypeDefaultDescription
xint—Left coordinate of the area (px).
yint—Top coordinate of the area (px).
widthint—Width of the area (px). Must be greater than zero.
heightint—Height of the area (px). Must be greater than zero.
ParameterTypeDefaultDescription
languagestring"eng"Text language: Tesseract code (eng, spa, eng+spa) or regional tag (es-CO, en-US). See language.

Returns a string with the text recognized in that region. If there is no readable text, it returns an empty string or one with only line breaks.

OCR Recognize Screen Region x = 100 y = 250 width = 400 height = 60 language = "spa" → output: balance
Set Variable name = balanceNumber value = regexFind(balance, "[\d.,]+")
MessageCause and fix
'width' and 'height' must be greater than zero.The area size is 0 or negative.
'x' is required. (same for y, width, height)One of the coordinates is missing.
Tesseract language '…' not found at '…'. Available: [eng, spa].The language code is not installed.
Screen capture errorThere is no interactive desktop (locked session or no user signed in). Run the robot in a session with an active desktop.