Skip to main content
Version: v6.5.0

Move the mouse over the OCR text

Command Description

Use OCR to recognize the specified text within the range of UI elements. If the specified text is recognized, move the cursor to the location of the text, and access the Internet is required when calling

Command Prototype

OCR.Hover(objUiElement,objRect,sEngine,sAcessKey,sSecretKey,sText,sRule,iOccurrence,iTimeOut,optionArgs)

Command parameter

parametermandatorytypedefault valueInstructions
objUiElementTruedecorator@ ui""Corresponding to the UI elements to be operated, when the attribute is passed as a string type, the UI elements is searched as a feature string. When the attribute is passed as a UiElement type, the UI elements corresponding to the UiElement is directly clicked
objRectTruedictionary{"x":0,"y":0,"width":0,"height":0}The program will perform OCR text recognition within the range of the control. If the range is passed as {"x": 0, "y": 0, "width": 0, "height": 0}, then text recognition will be performed within the rectangular area of the control
sEngineTrueenum"baidu2"The OCR engine used
sAcessKeyTruestring""ApiKey for OCR Services
sSecretKeyTruestring""Secret Key for OCR Service
sTextTruestring""Text used when searching for elements
sRuleTrueenum"instr"Rules used when searching for text
iOccurrenceTruenumberoneIf the string in the Text field appears more than once in the indicated UI elements, specify the number of occurrences to click here. For example, if the string appears 4 times and you want to click on the first match, write 1 in this field
iTimeOutTruenumberten thousandSpecifies the amount of time (in milliseconds) to wait for the Activity to run before the SelectorNotFoundException throws an exception. The default value is 10000 milliseconds (10 seconds)
bContinueOnErrorFalsebooleanFalseSpecifies whether automation should continue even if the Activity raises an error. This field only supports Boolean values (True, False). The default value is False
iDelayAfterFalsenumberthree hundredThe delay time (in milliseconds) after the execution of the Activity. The default time is 300 milliseconds
iDelayBeforeFalsenumbertwo hundredThe delay in milliseconds before the Activity starts performing any action. The default time limit is 200 milliseconds
bSetForegroundFalsebooleanTrueBefore performing the operation, should the target window be activated first
sCursorPositionFalseenum"Center"Describes the starting point of the cursor to add offsets for the OffsetX and OffsetY attribute. The following options can be used: TopLeft, TopRight, BottomLeft, BottomRight, and Center. The default option is Center
iCursorOffsetXFalsenumber0Horizontal displacement of cursor position based on the option selected in the 'Position' field
iCursorOffsetYFalsenumber0Vertical displacement of cursor position based on the option selected in the 'Position' field
sKeyModifiersFalseset[]The keyboard keys pressed simultaneously when triggering a mouse action can be selected using the following options: Alt, Ctrl, Shift, Win
sSimulateFalseenum"simulate"The selectable operation types are: background operation (uia), simulation operation (simulate), system message (message), and the default selection is simulation operation (simulate)

Run instance

/**************************Move Mouse to OCR Text**************************
Command prototype:
OCR.Hover(@ui"", {"x":0, "y":0, "width":0, "height":0}, "baidu2", "", "", "", "instr", 1, 10000,
{"bContinueOnError":false, "iDelayAfter":300, "iDelayBefore":200, "bSetForeground":true, "sCursorPosition":"Center", "iCursorOffsetX":0, "iCursorOffsetY":0, "sKeyModifiers":[], "sSimulate":"simulate"})
Input parameters:
objUiElement -- Recognition target.
objRect -- Target recognition range. Default value: {"x":0, "y":0, "width":0, "height":0}
sEngine -- OCR engine. Note: The OCR engine used.
sAccessKey -- Baidu OCR engine ApiKey. Note: ApiKey for OCR service (need to register OCR account and create application to get this parameter).
sSecretKey -- Baidu OCR engine SecretKey. Note: SecretKey for OCR service (need to register OCR account and create application to get this parameter).
sText -- Search text. Note: The text used when searching for elements.
sRule -- Search rule. Note: The rule used when searching for text.
iOccurrence -- Similar result position.
iTimeOut -- Timeout. Note: The amount of time (in milliseconds) to wait for the activity to run before SelectorNotFoundException is thrown. The default value is 10000 milliseconds (10 seconds).
optionArgs -- Optional parameters (including: continue execution on error, delay after execution, delay before execution, activate window, cursor position, horizontal offset, vertical offset, auxiliary keys, operation type). Type: Dict.
Notes:
1. This command calls the external Baidu OCR interface. You need to create a Baidu OCR account and corresponding application in advance, and obtain the corresponding Access Key and Secret Key of the application.
2. Ensure that the window for OCR operation exists; otherwise, the command execution will report an error.
3. An external network connection is required to run this command.
******************************************************************/

OCR.Hover(@ui"文本<span>_鼠标移动到OCR文本上",{"x":0,"y":0,"width":0,"height":0},"baidu2","P10qsjDcuoN5ZU7dnSHmXzGh","Fm8whYrNnXtKkSvqVPUYL573XfNbxlmO","文本","instr",1,10000,{"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200,"bSetForeground":true,"sCursorPosition":"Center","iCursorOffsetX":0,"iCursorOffsetY":0,"sKeyModifiers":[],"sSimulate":"simulate"})