Get Value

Gets the value contained inside a user interface control.

Command availability: IBM RPA SaaS and IBM RPA on premises

Script syntax

IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.

getValue [--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)] (String)=value (Numeric)=index (StringDictionary<String>)=selectedvalues (StringKeyValuePair<String>)=firstvalue

Dependencies

Use the Launch and Attach Window or Launch or Attach Window command to start the Windows scope before using the Get Value (getValue) command.

Input parameter

The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
Update screen cache forcerefresh Optional Boolean Enable to read the screen to identify new elements and update the screen cache. The readout of the screen occurs before running the command.

You must enable this parameter if there are any changes on the screen.
Selector selector Required ControlSelectors Type of selector to identify the user interface controls.

You can use the IBM RPA Studio's recorder to map the controls and obtain the information needed for this parameter.

See the selector parameter options.
Id id Required when the Selector parameter is Id, IdAndName Text The control's unique identifier.

In SAP GUI, use the ID selector to map a GridView control. See Mapping GridView controls for details on how GridView ID selectors work.
Name name Required when the parameter is Name, NameAndValue, IdAndName, TypeAndName Text The control name.
Text innertext Required when the Selector parameter is InnerTextAndTag Text The inner text the control displays.
Element Type tagname Required when the Selector parameter is InnerTextAndTag Text The tag name of the control.
XPath xpath Required when the Selector parameter is XPath Text The path through the control tree to the target control.
Class classname Required when the Selector parameter is ClassAndValue, ClassName Text The name of the class that instantiates the control.
Element Value elementvalue Required when the Selector parameter is ClassAndValue, NameAndValue Text The value stored by the control.
Type controltype Required when the Selector parameter is TypeAndIndex, TypeAndName ControlTypes The type of the control.

See the controltype parameter options
Index index Required when the Selector parameter is TypeAndIndex Number The position of the control. The index starts with zero being the first control among equal types.
Control control Required when the Selector parameter is Instance Control The control instance.

Obtain the Control variable type by the Search Control command.
Element in Table usetable Optional Boolean Searches for an element within a table when enabled.
Search by Column searchbycolumn Optional Boolean Enable to search for an element within a specific column of the table.
Column searchcolumn Required when the Element in Table parameter is True Text The column name or index where the element is searched for.
Value searchvalue Required when the Search by Column parameter is True Text The value used to search the element in the table.
Return Column returncolumn Required when the Search by Column parameter is True Text The column that contains the control.
Row row Required when the Search by Column parameter is False Number The row number to obtain the element.

To dismiss this parameter, enable the Search by Column parameter.
Timeout timeout Optional Time Span, Number, Text The maximum waiting time to find the control. When blank, the default timeout is 5 seconds.

selector parameter options

The following table displays the options available for the selector input parameter. The table shows the options available when working in Script mode and the equivalent label in the Designer mode.

Designer mode label Script mode name Description
Class and value ClassAndValue It matches the control class name and the value.
Class name ClassName It matches the class name that instantiates the control.
Id Id It matches the control's unique identifier.
Id and name IdAndName It matches the unique identifier and the control name.
Inner text and control type InnerTextAndTag It matches the control inner text and its type attributes.
Instance Instance It matches the control instance.
Name Name It matches the control name.
Name and value NameAndValue It matches the control name and the value.
Type and index TypeAndIndex It matches the control type and the index of its position among controls of equal type.
Type and name TypeAndName It matches the control type and the name.
Vision Vision It matches the mapped image that identifies the control.
XPath XPath It matches the path through the control tree to the target control.

You can use the IBM RPA Studio's recorder to map the controls and obtain the following selectors:

  • Class Name
  • Id
  • Inner Text
  • Link text
  • Name
  • Tag Name
  • XPath

controltype parameter options

The following table displays the options available for the controltype input parameter. The table shows the options available when working in Script mode and the equivalent label in the Designer mode.

Designer mode label Script mode name Description
Button Button It matches the Button control in the application.
Check box CheckBox It matches the Check box control in the application.
Child window ChildWindow It matches the Child window control in the application.
Combo box ComboBox It matches the Combo box control in the application.
Generic Generic It matches the Generic control in the application.
Image Image It matches the Image control in the application.
Label Label It matches the Label control in the application.
List box ListBox It matches the List box control in the application.
Menu bar MenuBar It matches the Menu bar control in the application.
Menu item MenuItem It matches the Menu item control in the application.
Progress bar ProgressBar It matches the Progress bar control in the application.
Radio button RadioButton It matches the Radio button control in the application.
Scroll bar ScrollBar It matches the Scroll bar control in the application.
Slider Slider It matches the Slider control in the application.
Spinner Spinner It matches the Spinner control in the application.
Status bar StatusBar It matches the Status bar control in the application.
Tab page TabPage It matches the Tab page control in the application.
Tab panel TabPanel It matches the Tab panel control in the application.
Table Table It matches the Table control in the application.
Text box TextBox It matches the Text box control in the application.
Toggle button ToggleButton It matches the Toggle button control in the application.
Tree view TreeView It matches the Tree view control in the application.
TreeTable TreeTable It matches the TreeTable control in the application.
Window Window It matches the Window control in the application.

Output parameter

Designer mode label Script mode name Accepted variable types Description
Value value Text Return the value contained in the UI control.
Index index Number Return the index of the selected item in the UI control as an item in a list.
Selected Values selectedvalues String Dictionary<Text> Return the value key of the values contained in the user interface control.
First Selected Value firstvalue String Key Value Pair<Text> Return the first value from values obtained on the UI control.

Example

The following code example demonstrates how to get a value from the Notepad application. The Get Value (getValue) command gets the values ​​contained in the user interface control that has the name "File". After the Notepad application closes, the Log Message (logMessage) command logs the value obtained.

defVar --name controlValue --type String
defVar --name notepadWindow --type Window
// Launch the notepad application 
launchWindow --executablepath "notepad.exe" notepadWindow=value
// Gets the value contained in the UI control that has the name "File" in Notepad
getValue --selector "Name" --name File controlValue=value
closeWindow --window ${notepadWindow}
// Logs the value obtained by the control
logMessage --message "Obtained control value: ${controlValue}" --type "Info"