Home > Language Reference > Capture Functions > CaptureAreaOCR$


The CaptureAreaOCR$ function returns the text that appears in the specified area of a window using OCR .


Used to capture a text displayed inside an image.

Video: How to capture a text area using OCR technique. The two OCR engines available in WinTask x64 are shown.


var$=CaptureAreaOCR$(<window_name>, <x>, <y>, <height>, <width> [,<language>])


<window_name>, string, name of the window to capture. The <window_name> must include the instance number.

<x>,<y>, integer, coordinates of the topleft point of the area to capture.

<height>,<width>, integer, size of the area to capture.

<language>, optional string, constant. It specifies the language used by the OCR engine. If this parameter is not specified, the language used is the one defined in Office settings. The WinTask x64 OCR engine does not take into account this optional parameter, it uses the default Windows language as defined in Windows Language and Region settings. Use CaptureAreaOCR$ wizard to generate the correct language string option.

Return value

var$, string. It contains the OCRized text seen in the area. If <window_name> is not found, or if there is nothing to capture, or if the OCR engine does not return any character, or if the speficied OCR engine is not installed, an empty string is returned (an empty string is "").


Generate the CaptureAreaOCR$ syntax using its wizard: in the Language pane of the WinTask x64 Editor, double-click the CaptureAreaOCR$ function name to start the wizard (if the Language pane is not displayed, press F4 or select Insert/Statement menu).

CaptureAreaOCR$ takes a bitmap of the specified area of the window, submits this bitmap to the OCR engine specified by last used UseOCREngine statement. If no previous UseOCREngine statement is in the script, the WinTask x64 OCR engine is used (default OCR engine).

The WinTask x64 OCR engine keeps the line structure (the CRLF), the MODI OCR engine does not keep it and so returns the OCRized text as a long string.

See also


How to install MODI OCR engine


ret = UseOCREngine(2) 'Forces to use WinTask x64 OCR engine
var$ = CaptureAreaOCR$("NOTEPAD.EXE|Edit|Untitled - Notepad|1",1,275,107,30,139) 'OCRized the text within the specified rectangle of window notepad.

ret = UseOCREngine(1) 'Forces to use MODI OCR engine
var$ = CaptureAreaOCR$("NOTEPAD.EXE|Edit|Untitled - Notepad|1",1,275,107,30,139,"Japanese") 'OCRized the text within the specified rectangle of window notepad. The MODI engine will use the Japanese language to transform the bitmap to Japanese text.

'Write in Excel a captured OCRized value:
'Using CaptureAreaOCR$ wizard, you have captured a data displayed on a Web page. And you need now to write that value to Excel.
'Declare at the beginning of the script the array which will be used for WriteExcel function.
Dim data$(10)

UsePage("My page")
ret = UseOCREngine(2)
'Capture the data
var$ = CaptureAreaOCR$("IEXPLORE.EXE|Internet Explorer_Server|my page - Microsoft Internet Explorer|1",1,160,592,43,238)

'Fill the first element of data$ array by var$
'You can capture other values and store them in data$(1), data$(2), etc.

'Then write this array in Excel
'tell where the Excel file is
'Fill the C1 to C10 column using WriteExcel function