Home > Language Reference > Capture Functions > CaptureOCR$

CaptureOCR$

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

Usage

Used to capture a text displayed inside an image.

Video: How to use the WinTask CaptureOCR$ function for capturing the content of a whole window and OCRized it.

Syntax

var$=CaptureOCR$(<window_name> [, <language>])

Parameters

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

<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 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 CaptureOCR$ wizard to generate the correct language string option.

Return value

var$, string. It contains the OCRized text seen in the window. 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 emty string is "").

Remarks

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

CaptureOCR$ takes a bitmap of the specified window (the visible part, it does not scroll), submits this bitmap to the OCR engine specified by last used UseOCREngine statement. If no previous UseOCREngine statement is in the script, the WinTask OCR engine is used (default OCR engine).

The WinTask 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

Capture$
CaptureArea$
CaptureAreaOCR$
CaptureBitmap
HardCopy

How to install MODI OCR engine

Examples

var$=CaptureOCR$("NOTEPAD.EXE|Edit|Untitled - Notepad|1",1) 'var$ returns the OCRized text which is seen in the Notepad window.
'The OCRengine used is the WinTask one.

UseOCREngine(1)
var$=CaptureOCR$("NOTEPAD.EXE|Edit|Untitled - Notepad|1",1) 'var$ returns the OCRized text which is seen in the Notepad window.
'The OCRengine used is the MODI one.

UseOCREngine(1)
var$=CaptureOCR$("NOTEPAD.EXE|Edit|Untitled - Notepad|1",1,"Japanese") 'var$ returns the OCRized text which is seen in an English Notepad window using Japanese language for the text within the notepad window.
'The OCRengine used is the MODI one.

 

'This script ocrizes the text that has been typed by the user in the notepad window, using WinTask OCR engine.
shell("notepad")
Msgbox("Write some text in notepad and press F12")
 
Pause until
Key("<F12>")
PauseFalse
MsgBox("Pause at line " + #ErrorLine$ + " has failed !",16,"Runtime error")
End
EndPause
 
' captures your text in notepad
text$=CaptureOCR$("NOTEPAD.EXE|Edit|Untitled - Notepad|1",1)
msgbox("Your text is : "+text$)
 

'This script ocrizes the text that has been typed by the user in the notepad window, using MODI OCR engine.
shell("notepad")
Msgbox("Write some text in notepad and press F12")
 
Pause until
Key("<F12>")
PauseFalse
MsgBox("Pause at line " + #ErrorLine$ + " has failed !",16,"Runtime error")
End
EndPause
 
' captures your text in notepad using MODI OCR engine.
UseOCREngine(1)
text$=CaptureOCR$("NOTEPAD.EXE|Edit|Untitled - Notepad|1",1)
msgbox("Your text is : "+text$)

 

 

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.