单击
单击用户界面 (UI) 元素或双击该元素。
命令可用性: 本地 IBM RPA SaaS 和 IBM RPA
Description
您可以使用此命令来利用脚本的表面自动化功能。 有关更多信息,请参阅 用于表面自动化的操作。
脚本语法
IBM RPA 的专有脚本语言的语法与其他编程语言类似。 该脚本语法在脚本文件中定义命令的语法。 您可以在 IBM RPA Studio的 脚本 方式下使用此语法。
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)]
依赖关系
在使用 单击 (
click) 命令之前,请使用 启动并附加窗口 (launchWindow) 或 启动或附加窗口 (launchOrAttach) 命令 来启动 Windows 作用域。使用 Focus (
focus) 或 Focus Window (focusWindow) 命令,并在 使用 单击 (click) 命令以正确运行 模拟人员 (simulatehuman) 参数之前将显示比例保持在 100%。
输入参数
下表显示了此命令中提供的输入参数的列表。 在表中,您可以看到在 IBM RPA Studio的脚本方式及其 Designer 方式等效标签中工作时的参数名称。
| 设计器方式标签 | 脚本方式名称 | 必需的 | 接受的变量类型 | Description |
|---|---|---|---|---|
| 与屏幕相关 | clickOnScreen |
Optional when the Selector parameter is Vision |
Boolean |
启用以单击与屏幕相关的内容,而不是单击窗口或控件。 |
| 安全搜索 | safesearch |
Optional |
Boolean |
启用以将焦点放在屏幕上,并使用更高质量的图像而不是图像参数中定义的图像。 使用此设置时,命令运行时可能会有点慢。 |
| 选择器 | selector |
Required |
ControlSelectors |
用于标识用户界面控件的选择器类型。 您可以使用 IBM RPA Studio的记录器来映射控件并获取此参数所需的信息。 请参阅 选择器参数选项。 |
| 双击 | doubleclick |
Optional |
Boolean |
启用以双击。 |
| 右边按钮 | rightbutton |
Optional if the In Relation to the Screen parameter is enabled |
Boolean |
启用以右键单击。 |
| 单击位置 | clickonposition |
Optional |
Boolean |
启用以单击屏幕上的特定位置。 |
| 角 | corner |
Optional |
ControlCorner |
选择要单击的屏幕上的角位置。 请参阅角参数选项。 |
| Image | visionimage |
Required when the Selector parameter is Vision |
Image |
屏幕区域的图像,作为单击的参考。 |
| 相似度 | visionsimilarity |
Required when the Selector parameter is Vision |
Number |
达到图像参数中所定义图像的相似度(百分比)。 |
| 控制图像 | controlimage |
Optional |
Image |
屏幕区域的图像,作为单击的参考。 |
| 相似度 | controlsimilarity |
Optional |
Number |
达到控件图像参数中所定义图像的相似度(百分比)。 |
| X 偏移量(已废弃) | deltax |
Optional |
Number |
水平偏移量(像素)。 该参数已废弃,请改为使用位置参数。 |
| Y 偏移量(已废弃) | deltay |
Optional |
Number |
垂直偏移量(像素)。 该参数已废弃,请改为使用位置参数。 |
| 位置 | position |
Required when the Click on Position parameter is True |
Point |
屏幕上的位置。 此位置表示要运行单击操作的整数 X 和 Y 坐标的有序对中的一个点。 该位置可能会根据屏幕分辨率而更改。 您可以使用 IBM RPA Studio 点选择器来获取位置坐标。 |
| 区域 | region |
Optional |
Rectangle |
屏幕上可单击的区域。 您可以使用 IBM RPA Studio 区域选择器或记录器截图工具来获取区域坐标。 |
| 模拟人类 | simulatehuman |
Optional |
Boolean |
启用以模拟单击用户界面控件的人类手势。 |
| 表中的元素 | usetable |
Optional |
Boolean |
启用以搜索表中的元素。 |
| 更新屏幕高速缓存 | forcerefresh |
Optional |
Boolean |
启用以读取屏幕来识别新元素和更新屏幕高速缓存。 在运行该命令之前会读取屏幕。 如果屏幕上有任何更改,那么必须启用此参数。 |
| 标识 | id |
Required when the Selector parameter is Id, IdAndName |
Text |
控件的唯一标识。 在 SAP GUI 中,使用标识选择器来映射 GridView 控件。 有关 GridView 标识选择器如何工作的详细信息,请参阅在 SAP 自动化中处理 GridView 控件。 |
| 名称 | name |
Required when the Selector parameter is Name, NameAndValue, IdAndName, TypeAndName |
Text |
控件名称。 |
| 文本 | innertext |
Required when the Selector parameter is InnerTextAndTag |
Text |
控件所显示的内部文本。 |
| 元素类型 | tagname |
Required when the Selector parameter is InnerTextAndTag |
Text |
控件的标记名称。 |
| XPath | xpath |
Required when the Selector parameter is XPath |
Text |
通过控件树到目标控件的路径。 |
| 类 | classname |
Required when the Selector parameter is ClassAndValue, ClassName |
Text |
用于实例化控件的类的名称。 |
| 元素值 | elementvalue |
Required when the Selector parameter is ClassAndValue, NameAndValue |
Text |
通过控件存储的值。 |
| 类型 | controltype |
Required when the Selector parameter is TypeAndIndex, TypeAndName |
ControlTypes |
控件的类型。 请参阅 controltype 参数选项。 |
| 索引 | index |
Required when the Selector parameter is TypeAndIndex |
Number |
控件位置。 索引以零开头,它是同等类型中的第一个控件。 |
| 控件 | control |
Required when the Selector parameter is Instance |
Control |
控件实例。 通过搜索控件命令来获取 Control 变量类型。 |
| 按列搜索 | searchbycolumn |
Optional |
Boolean |
启用以在表的特定列中搜索元素。 |
| 列 | searchcolumn |
Required when the Element in Table parameter is True |
Text |
要在其中搜索元素的列。 |
| 值 | searchvalue |
Required when the Search by Column parameter is True |
Text |
这是用于在表中搜索元素的值。 |
| 返回列 | returncolumn |
Required when the Search by Column parameter is True |
Text |
包含控件的列。 |
| 行 | row |
Required when the Search by Column parameter is False |
Number |
用于获取元素的行号。 要关闭此参数,请启用按列搜索参数。 |
| 超时 | timeout |
Optional |
Time Span, Number, Text |
查找控件所需的最长等待时间。 如果为空白,那么缺省超时为 5 秒。 |
selector 参数选项
下表显示了可用于 selector 输入参数的选项。 该表显示了在脚本方式下工作时的可用选项以及在设计器方式下的等效标签。
| 设计器方式标签 | 脚本方式名称 | Description |
|---|---|---|
| 类和值 | ClassAndValue |
它与控件类名和值匹配。 |
| 类名 | ClassName |
它与用于实例化控件的类名匹配。 |
| 标识 | Id |
它与控件的唯一标识匹配。 |
| 标识和名称 | IdAndName |
它与唯一标识和控件名称匹配。 |
| 内部文本和控件类型 | InnerTextAndTag |
它与控件内部文本及其类型属性匹配。 |
| 实例 | Instance |
它与控件实例匹配。 |
| 名称 | Name |
它与控件名称匹配。 |
| 名称和值 | NameAndValue |
它与控件名称和值匹配。 |
| 类型和索引 | TypeAndIndex |
它与控件类型及其在同等类型控件中的位置索引相匹配。 |
| 类型和名称 | TypeAndName |
它与控件类型和名称匹配。 |
| 视觉 | Vision |
它与标识控件的映射图像匹配。 |
| XPath | XPath |
它与通过控件树到目标控件的路径匹配。 |
您可以使用 IBM RPA Studio 的记录器来映射控件和获取以下选择器:
- 类名
- 标识
- 内部文本
- 链接文本
- 名称
- 标记名称
- XPath
corner 参数选项
下表显示了可用于 corner 输入参数的选项。 该表显示了在脚本方式下工作时的可用选项以及在设计器方式下的等效标签。
| 设计器方式标签 | 脚本方式名称 | Description |
|---|---|---|
| 左下方 | BottomLeft |
它与相对于屏幕位置的左下角匹配。 |
| 右下方 | BottomRight |
它与相对于屏幕位置的右下角匹配。 |
| 左上方 | TopLeft |
它与相对于屏幕位置的左上角匹配。 |
| 右上方 | TopRight |
它与相对于屏幕位置的右上角匹配。 |
controltype 参数选项
下表显示了可用于 controltype 输入参数的选项。 该表显示了在脚本方式下工作时的可用选项以及在设计器方式下的等效标签。
| 设计器方式标签 | 脚本方式名称 | Description |
|---|---|---|
| 按钮 | Button |
它与应用程序中的“按钮”控件匹配。 |
| 复选框 | CheckBox |
它与应用程序中的“复选框”控件匹配。 |
| 子窗口 | ChildWindow |
它与应用程序中的“子窗口”控件匹配。 |
| 组合框 | ComboBox |
它与应用程序中的“组合框”控件匹配。 |
| 常规 | Generic |
它与应用程序中的“常规”控件匹配。 |
| Image | Image |
它与应用程序中的“图像”控件匹配。 |
| 标签 | Label |
它与应用程序中的“标签”控件匹配。 |
| 列表框 | ListBox |
它与应用程序中的“列表框”控件匹配。 |
| 菜单栏 | MenuBar |
它与应用程序中的“菜单栏”控件匹配。 |
| 菜单项 | MenuItem |
它与应用程序中的“菜单项”控件匹配。 |
| 进度条 | ProgressBar |
它与应用程序中的“进度条”控件匹配。 |
| 单选按钮 | RadioButton |
它与应用程序中的“单选按钮”控件匹配。 |
| 滚动条 | ScrollBar |
它与应用程序中的“滚动条”控件匹配。 |
| 滑块 | Slider |
它与应用程序中的“滑块”控件匹配。 |
| 微调器 | Spinner |
它与应用程序中的“微调器”控件匹配。 |
| 状态栏 | StatusBar |
它与应用程序中的“状态栏”控件匹配。 |
| 选项卡页面 | TabPage |
它与应用程序中的“选项卡页面”控件匹配。 |
| 选项卡面板 | TabPanel |
它与应用程序中的“选项卡面板”控件匹配。 |
| 表 | Table |
它与应用程序中的“表”控件匹配。 |
| 文本框 | TextBox |
它与应用程序中的“文本框”控件匹配。 |
| 切换按钮 | ToggleButton |
它与应用程序中的“切换按钮”控件匹配。 |
| 树形视图 | TreeView |
它与应用程序中的“树形视图”控件匹配。 |
| TreeTable | TreeTable |
它与应用程序中的“树表”控件匹配。 |
| 窗口 | Window |
它与应用程序中的“窗口”控件匹配。 |
示例
下面代码示例演示了如何单击 MSPaint 应用程序中的用户界面控件。 单击 (click) 命令将单击带有颜色的填充、颜色选取器和文本工具,并使用每个按钮的名称来识别这些工具。 延迟 (delay) 命令将在运行下一个命令之前等待 3 秒。
// 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"