CaptureAreaOCR$
Capture function.
The CaptureAreaOCR$ function captures the text that appears in the specified area of a window using OCR (not available in WinTask Lite).
Syntax
a$=CaptureAreaOCR$(<window_name>,<instance>,<x>,<y>,<height>,<width> [,<language>])
Parameters
<window_name>, window name of the window to be captured, including its <instance>, instance number of the window.
<x>,<y>, coordinates of the top-left corner of the rectangle to be captured within the specified window.
<height>,<width>, integers specifying the height and the width of the rectangle to capture.
<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 Office 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 CaptureAreaOCR$ 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 speficied OCR engine is not installed, an empty string is returned.
Remarks
Use the Insert/Statement menu and double click CaptureAreaOCR$ in order to automatically generate this statement.
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 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
Examples
ret = UseOCREngine(2) 'Forces to use WinTask 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$
data$(0)=var$
'You can capture other values and store them in data$(1), data$(2), ...
'Then write this array in Excel
'tell where the Excel file is
fileexcel$="c:\program files\wintask\data\myexcel.xls"
'Fill the C1 to C10 column using WriteExcel function
WriteExcel(fileexcel$,"C1:C10",data$())