ClickOnTextOCR

Windows management and Capture function.

The ClickOnTextOCR function clicks the specified text recognized by the OCR engine (or clicks near it). Not available in WinTask Lite.

Usage

Sometimes, a text to click on is a "graphic" text and the only way to record/replay a click on it is either to use ClickOnBitmap function or ClickOnTextOCR function. ALWAYS use the ClickOnTextOCR wizard to generate the parameters for this function, it is the only way to check that the OCR engine will recognize correctly the specified text at replay.

Syntax

ClickOnTextOCR(<text>,<action>,<button>, InArea(<x>,<y>,<height>,<width>), <offset_x>,<offset_y> [,<language>])
or
ret=ClickOnTextOCR(<text>,<action>,<button>, InArea(<x>,<y>,<height>,<width>), <offset_x>,<offset_y> [,<language>])

Parameters

<text>, string (variable or constant) : the mouse click is made on that <text>. During the time delay specified by #ActionTimeout, the OCR engine captures the screen portion specified in InArea, converts the image in text and tries to find this <text> in the window specified by the last statement UseWindow and clicks. Such a function UseWindow must be just before the ClickOnTextOCR. If the text is not found by the OCR engine in the specified area, a return code of 8 is setup but no execution error is reported and the script continues.

<Action>: single or double click.

<Button>: mouse button used to click the text, the keywords are Left or Right or Middle.

InArea(<x>,<y>,<height>,<width>): screen portion to capture and then where to look for the <text>.

<offset_x>,<offset_y> : coordinates of the click offset from the middle of the specified text. If these values are 0, the click occurs in the middle of the text. These offsets allow you, for example, to click an icon just above the specified text.

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

Return value

Ret, numeric return code. When the text is found, the function returns 0, otherwise this return code has a value different from 0 (1 if the text is not found).

Remarks

ClickOnTextOCR can use two different OCR engines, the default one is the WinTask OCR engine. If WinTask OCR engine is used, the click at replay is done in the middle of the rectangle specified in the ClickOnTextOCR function. If MODI OCR engine is used, the click at replay is done on the exact word as specified in <text> parameter. You can force the use of MODI OCR engine by adding the line UseOCREngine(1) before the ClickOnTextOCR call (the ClickOnTextOCR wizard generates this line automatically). Of course, if the MODI OCR engine is not installed, script execution will return an error.

 

ALWAYS use the ClickOnTextOCR wizard (Insert/Statement menu and select ClickOnTextOCR function) to generate the ClickOnTextOCR parameters, the wizard allows to check that the specified text will be correctly recognized by the OCR engine at replay. NEVER change manually the <text> parameter.

In the wizard dialog box, click Capture. The mouse pointer changes shape ; draw a rectangle around the text WinTask must click on. Release the mouse.
The captured bitmap transformed by the OCR engine is now in the "Text" field. If the results do not give a readable text, Capture a new area.
The "Window" field is for information only. It displays the window name where the text must be captured.
From the text as transformed by the OCR engine (field "Text"), copy a small correctly transformed part of the text and paste it in the field "From the text seen by OCR engine field, copy and paste below the text you want to click on:". Click Check button to check that at replay, the text that you have pasted in that field will be recognized correctly by the OCR engine. This Check process makes a mouse move on the text which will be recognized at replay.
Click Paste into the script to paste the ClickOnTextOCR statement into the script.

Examples

 

StartBrowser("IE", "www.wintask.com")

UseWindow( "IEXPLORE.EXE|Internet Explorer_Server|WinTask",1 )

 ClickOnTextOCR("aise", left, single, InArea(1087, 118, 93, 13))

'Using MODI OCR engine

StartBrowser("IE", "www.wintask.com")
UseOCREngine(1)

UseWindow( "IEXPLORE.EXE|Internet Explorer_Server|WinTask",1 )

 ClickOnTextOCR("aise", left, single, InArea(1087, 118, 93, 13))