Focus
Verb: focus
Focuses on a UI control.
Controls are, in the context of Windows, elements that allow the user to interact with an application. Controls can be buttons, data entry fields, menus, and many others.
Syntax
focus [--forcerefresh(Boolean)] --selector(ControlSelectors) --id(String) --name(String) --innertext(String) --tagname(String) --xpath(String) --classname(String) --elementvalue(String) --controltype(Nullable<ControlTypes>) --index(Numeric) --control(Control) [--usetable(Boolean)] [--searchbycolumn(Boolean)] --searchcolumn(String) --searchvalue(String) --returncolumn(String) --row(Numeric) [--timeout(TimeSpan)]
Inputs
Script | Designer | Required | AcceptedTypes | Description |
---|---|---|---|---|
--forcerefresh | Update screen cache | Optional | Boolean | When enabled, performs a new reading of the screen before executing the command to identify new elements and update the screen cache.
This identification is necessary for the command to work, in case there are any changes on the screen. |
--selector | Selector | Required | ControlSelectors | Type of selector used to identify user interface controls. The following options are available:
|
--id | ID | Only whenSelector is Id, IdAndName | Text | Id of the UI control. |
--name | Name | Only whenSelector is Name, NameAndValue, IdAndName, TypeAndName | Text | Name of the UI control. |
--innertext | Inner text | Only whenSelector is InnerTextAndTag | Text | Internal text of the UI control element. |
--tagname | Element type | Only whenSelector is InnerTextAndTag | Text | Type of the element or tag.
Eg: “button”, “text box”. |
--xpath | XPath | Only whenSelector is XPath | Text | Xpath of the UI control. |
--classname | Class | Only whenSelector is ClassAndValue, ClassName | Text | class of the UI control. |
--elementvalue | Element value | Only whenSelector is ClassAndValue, NameAndValue | Text | Current value of the UI control element. |
--controltype | Control type | Only whenSelector is TypeAndIndex, TypeAndName | ControlTypes | UI control type. You have the following options:
|
--index | Index | Only whenSelector is TypeAndIndex | Number | Index of the UI control. |
--control | Control | Only whenSelector is Instance | Control | Control instance.
This variable is obtained using the command Search Control. |
--usetable | Element is in table | Optional | Boolean | Searches for an element within the table when enabled. |
--searchbycolumn | Lookup | Optional | Boolean | When enabled, fetches the element through the column, not by row. |
--searchcolumn | Search column | Only whenElement is in table is True | Text | Name or number of the column from which the element is taken. |
--searchvalue | Search value | Only whenLookup is True | Text | Value used to find the element in the table. |
--returncolumn | Return column | Only whenLookup is True | Text | Column that contains the control. |
--row | Row | Only whenLookup is False | Number | Table row where the element is obtained. |
--timeout | Timeout | Optional | Time Span, Number, Text | Maximum time to execute the command.
In case no value is defined for the timeout parameter, the execution uses the context timeout defined by the Set Timeout command. If that command is not used on the script, the default timeout is 5 seconds. |
Example
After opening the test application, the Focus command focuses on the "First Name" field, previously mapped by the IBM RPA Studio's recorder tool.
defVar --name varWindow --type Window
// Open the executable.
// Download the following file to execute the command.
launchWindow --executablepath "CSharpTestApp.exe" varWindow=value
focus --selector "IdAndName" --id txtFirtName --name "Last Name:"
closeWindow --window ${varWindow}
For the above script to work correctly, you must download the file and enter its path in the Executable parameter of the Launch and Attach Window command.
Remarks
To find out the value to use in the ID, Name , Inner text , Element type , XPath, Class , Element value , Control type and Index parameters, use the recorder feature available in IBM RPA Studio.
The parameter Search column is only required if the parameter Element is in table is active.
The Row parameter is only required if the Element is in table parameter is active and the Lookup parameter is inactive.
The Search value and Return column parameters are only required if the Lookup parameter is active.