Click

Click or double click on a user interface (UI) element.

Command availability: IBM RPA SaaS and IBM RPA on premises

Description

You can use this command to leverage surface automation capabilities to your script. For more information, see Actions for surface automation.

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.

click [--clickOnScreen(Boolean)] [--safesearch(Boolean)] --selector(ControlSelectors) [--doubleclick(Boolean)] [--rightbutton(Boolean)] [--clickonposition(Boolean)] [--corner(Nullable<ControlCorner>)] --visionimage(Image) --visionsimilarity(Numeric) [--controlimage(Image)] [--controlsimilarity(Numeric)] --position(Point) [--region(Rectangle)] [--simulatehuman(Boolean)] [--usetable(Boolean)] [--forcerefresh(Boolean)] --id(String) --name(String) --innertext(String) --tagname(String) --xpath(String) --classname(String) --elementvalue(String) --controltype(Nullable<ControlTypes>) --index(Numeric) --control(Control) [--searchbycolumn(Boolean)] --searchcolumn(String) --searchvalue(String) --returncolumn(String) --row(Numeric) [--timeout(TimeSpan)]

Dependencies

  • Use the Launch and Attach Window (launchWindow) or Launch or Attach Window (launchOrAttach) commands to start the Windows scope before using the Click (click) command.

  • Use the Focus (focus) or Focus Window (focusWindow) commands and keep the display scale at 100% before using the Click (click) command for correct functioning of the Simulate Human (simulatehuman) parameter.

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
In Relation to the Screen clickOnScreen Optional when the Selector parameter is Vision Boolean Enable to click in relation to the screen instead of a window or control.
Safe Search safesearch Optional Boolean Enable to focus on the screen and use a higher quality image instead of the image defined in the Image parameter.

The command runtime might be a little slower with this setting.
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.
Double Click doubleclick Optional Boolean Enable to double click.
Right Button rightbutton Optional if the In Relation to the Screen parameter is enabled Boolean Enable to right-click.
Click on Position clickonposition Optional Boolean Enable to click on a specific position on the screen.
Corner corner Optional ControlCorner Select the corner of the position on the screen to click.

See the corner parameter options.
Image visionimage Required when the Selector parameter is Vision Image The image of a screen region as a reference for the click.
Similarity Degree visionsimilarity Required when the Selector parameter is Vision Number The degree of similarity, in percentage, to reach about the image defined in the Image parameter.
Control Image controlimage Optional Image The image of a screen region as a reference for the click.
Similarity Degree controlsimilarity Optional Number The degree of similarity, in percentage, to reach about the image defined in the Control Image parameter.
X offset (Obsolete) deltax Optional Number The horizontal offset in pixels.

Parameter obsolete, use the Position parameter instead.
Y offset (Obsolete) deltay Optional Number The vertical offset in pixels.

Parameter obsolete, use the Position parameter instead.
Position position Required when the Click on Position parameter is True Point The position on the screen. This position represents a point in an ordered pair of integer X and Y coordinates to run the click.

The position might change according to the screen resolution.

You can use the IBM RPA Studio point selector to get the position coordinates.
Region region Optional Rectangle The region on the screen for the click.

You can use the IBM RPA Studio region selector or the recorder snipping tool to get the region coordinates.
Simulate Human simulatehuman Optional Boolean Enable to simulates a human gesture clicking on the user interface control.
Element in Table usetable Optional Boolean Enable to search for an element within a table.
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.
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 Handling GridView controls in SAP automation for details on how GridView ID selectors work.
Name name Required when the Selector parameter is Name, NameAndValue, IdAndName, TypeAndName Text The control name.
Text innertext Required when the Selector parameter is InnerTextAndTag Text The inner text that 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.
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 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

corner parameter options

The following table displays the options available for the corner 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
Bottom left BottomLeft It matches the bottom left corner relative to the screen position.
Bottom right BottomRight It matches the bottom right corner relative to the screen position.
Top left TopLeft It matches the top left corner relative to the screen position.
Top right TopRight It matches the top right corner relative to the screen position.

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.

Example

The following code example demonstrates how to click in a user interface control in the MSPaint application. The Click (click) command clicks on the fill with color, the color picker, and the text tools, using the name of each button to identify them. The Delay (delay) command waits 3 seconds before run the next command.

// Launch the MsPaint application 
launchWindow --executablepath "mspaint.exe"
// Single click in the UI control with the "Fill with color" name
click --selector "Name" --controlsimilarity 100 --name "Fill with color" --timeout "00:00:30"
// Waits three seconds to run the next command
delay --timeout "00:00:03"
// Single click in the UI control with the "Color picker" name
click --selector "Name" --controlsimilarity 100 --name "Color picker" --timeout "00:00:30"
// Waits three seconds to run the next command
delay --timeout "00:00:03"
// Single click in the UI control with the "Text" name
click --selector "Name" --controlsimilarity 100 --name Text
// Waits three seconds to run the next command
delay --timeout "00:00:03"