OCR Recognize Screen Region
OCR Recognize Screen Region
Section titled “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.
How it works
Section titled “How it works”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".
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
x | int | — | Left coordinate of the area (px). |
y | int | — | Top coordinate of the area (px). |
width | int | — | Width of the area (px). Must be greater than zero. |
height | int | — | Height of the area (px). Must be greater than zero. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
language | string | "eng" | Text language: Tesseract code (eng, spa, eng+spa) or regional tag (es-CO, en-US). See language. |
Output
Section titled “Output”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.
Example
Section titled “Example”OCR Recognize Screen Region x = 100 y = 250 width = 400 height = 60 language = "spa" → output: balanceSet Variable name = balanceNumber value = regexFind(balance, "[\d.,]+")Common errors
Section titled “Common errors”| Message | Cause 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 error | There is no interactive desktop (locked session or no user signed in). Run the robot in a session with an active desktop. |
Related activities
Section titled “Related activities”- OCR Screenshot — read the whole screen.
- OCR Find Text — find the position of a text on screen.
- Win Get Text — robust alternative via UIA.