Skip to main content

Find-Text-Position

Command Description

Use Laiye IDP to find text position. The dictionary-type text position will be returned when succeeded, and an exception will be thrown if failed

Command Prototype

objPoint = Mage.Find(objElement, objRect,config,sText, sRule, iOccurrence, iTimeOut, optionArgs)

Parameter Description

ParameterRequiredTypeDefaultDescription
objElementTruedecorator@ui""Use mouse to select or cut off the target screen area including window, elements, range, etc
objRectTruedictionary{"x":0,"y":0,"width":0,"height":0}The range that needs OCR text recognition, the program will perform text recognition in this range of the control, if the range is passed as {"x":0,"y":0,"width":0,"height":0}, then Perform text recognition within the rectangular area of the control
configTrueexpression{}Call configuration of Laiye IDP
sTextTruestring""The text used for finding elements
sRuleTrueenum"instr"The rule used for finding text
iOccurrenceTruenumber1If the string in the Text field appears multiple times in the indicated UI element, specify the number of occurrences to click, for example, if the string appears 4 times and you want to click the first match, please Write 1 in this field
iTimeOutTruenumber30000Specify the time in milliseconds to wait for a retry to find the text. If exceeded, an exception will be thrown. Default: 30,000 milliseconds (30 seconds)
bContinueOnErrorNonebooleanNoneSpecify whether the automation should continue to support this field even if the activity is incorrect, it is only supported by the Boolean value (true, false) default value
iDelayAfterNonenumber300Delay time (in milliseconds) after executing the activity is 300 milliseconds
iDelayBeforeNonenumber200The delay time (in milliseconds) before any operations are executed is by default 200 milliseconds

return

objPoint,The variable used to save the output of the command.

Demo

Dim objRect={"x":0,"y":0,"width":0,"height":0}  // Default recognition range 
Dim config={"Pubkey":"","Secret":"","Url":""} // Get from mage
Dim optionArgs={"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200} // Default optional parameters

TracePrint "--------------------find text position--------------------"
// --------------------------------------------------------
// [Remarks] Find the text position
// Input parameter 1:
// objElement--target, in this example, the "Baidu click" button element used in chrome to open the Baidu homepage
// Input parameter 2:
// objRect--Recognition range. Default value: {"x":0,"y":0,"width":0,"height":0}
// Input parameter 3:
// config--mage configuration, need to configure Pubkey and Secret.Type:Dict
// Input parameter 4:
// sText--find text
// Input parameter 5:
// sRule--find rules
// Input parameter 6:
// iOccurrence--similar result position
// Input reference 7:
// iTimeOut--timeout time. Default unit: milliseconds. Type: Int
// Into reference 8:
// optionArgs--Optional parameters (including: error continue execution/delay after execution/delay before execution/cursor position/abscissa offset/ordinate offset/assistant key/operation type). Type:Dict

// Output parameters:
// objPoint--the variable to which the output of the function call is saved

// 命令原型:objPoint = Mage.Find(objElement, objRect,config,sText, sRule, iOccurrence, iTimeOut, optionArgs)
// --------------------------------------------------------

objPoint = Mage.Find(@ui"Input control<input>_Baidu Yi 3", objRect,config,"Baidu Yi", "instr", 1, 30000, optionArgs)