Skip to main content

Enter-in-Target

Command Description

Input text in the specified interface element

Command Prototype

Keyboard.InputText(objUiElement,sText,bEmptyField,iDelayBetweenKeys,iTimeOut,optionArgs)

Parameter Description

ParameterRequiredTypeDefaultDescription
objUiElementTruedecorator@ui""When the attribute is transferred as a string, it is used as the characteristic string to find the interface element. When the attribute is transferred as UiElement, directly click on the corresponding interface element
sTextTruestring""Write text into the specified interface element
bEmptyFieldTruebooleanTrueWhether to clear the input box before writing the text
iDelayBetweenKeysTruenumber20The interval between two input(only effective when Simulation operation is chosen in the attribute of operation type); If the interval is less than 20 milliseconds, it will be automatically converted to 20 milliseconds. If the interval is too short, it might lead to the word loss during the input. It is also affected by the machine performance
iTimeOutTruenumber10000Specify the amount of time (in milliseconds) that wait for the event to run before selectorNotFoundException to trigger an error (in milliseconds) The default value is 10,000 ms (10 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
iDelayBeforeNonenumber500The delay time (in milliseconds in milliseconds) before the event is executed, and the amount of time is 500 milliseconds, too short may lead to leak input
bSetForegroundNonebooleanTrueWhether to activate the target window before executing
sSimulateNoneenum"message"You can choose Operation Type as: Background Operation (UIA), Simulation Operation (Simulate), System Message (MersSage), Default Selection: System Message (Message)
bValidateNonebooleanNoneIf the property of "Write Text" and the actual input are the same, continue to run. Otherwise, throw an error
bClickBeforeInputNonebooleanNoneAfter finding the target, first click on the target and then enter the content

Demo

TracePrint "--------------------Enter in target--------------------" 
// --------------------------------------------------------
// [Remarks] Enter in the target, the Demo is to enter "UiBot" in the Baidu search bar
// Input parameter 1:
// objUiElement--target element
// Input parameter 2:
// sText--write text
// Input parameter 3:
// bEmptyField--clear the original content
// Input parameter 4:
// iDelayBetweenKeys--type interval (ms)
// Input parameter 5:
// iTimeOut--timeout time. Default unit: milliseconds. Type: Int
// Input parameter 6:
// optionArgs--Optional parameters (including: error continue execution/delay after execution/delay before execution/activation window/operation type/verify written text/click before input).Type:Dict

// Command Prototype:Keyboard.InputText(objUiElement,sText,bEmptyField,iDelayBetweenKeys,iTimeOut,optionArgs)
// --------------------------------------------------------

Keyboard.InputText(@ui"Input Controls<input>","UiBot",true,20,10000,{"bContinueOnError": false, "iDelayAfter": 300, "iDelayBefore": 500, "bSetForeground": true, "sSimulate": "message", "bValidate": false, "bClickBeforeInput": false})