CaptureOCR$

Capture function.

The CaptureOCR$ function captures the text that is seen in the specified window using OCR (not available in WinTask Lite).

Syntax

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

Parameters

<window_name>, window name of the window to be captured, including its <instance>, instance number of the window.

<language>, optional string specifying which language must be used by the OCR engine. If this parameter is not specified, the language used is the one defined in Regional settings. The WinTask OCR engine does not take into account this optional parameter, it uses the default Windows language as defined in Regional settings. Use CaptureOCR$ wizard to generate the correct language string option.

Return value

a$, string containing the OCRized text seen in the window. If <window_name> or <instance> are not found, if there is nothing to capture, if the OCR engine does not return any character, or if the specified OCR engine is not installed, an empty string is returned.

Remarks

Use the Insert/Statement menu and double click CaptureOCR$ in order to automatically generate this statement.

CaptureOCR$ takes a bitmap of the specified window, capturing only the window part which is seen on the screen (it does not take the text which can be seen by scrolling 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 OCR engine is used (OCR engine per default).

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

CaptureAreaOCR$

UseOCREngine

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.

 

Example code

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$)