获取控件
动词:getControl
从控件获取信息。
语法
getControl --selector(ControlSelectors) [--forcerefresh(Boolean)] --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)] (Control)=control (Rectangle)=bounds (Numeric)=handle (String)=class
输入
| 脚本 | 设计器 | 必需的 | AcceptedTypes | Description |
|---|---|---|---|---|
| --selector | 选择器 | 必需的 | ControlSelectors | 用于识别用户界面控件的选择器的类型。 提供了以下选项:除了在自动补全脚本中插入命令外,还可以使用 IBM RPA Studio的记录器来映射控件并从 "Selector" 参数获取必要的信息。 该记录器在平台上的上方工具栏中可用。 |
| --forcerefresh | 更新屏幕高速缓存 | 可选 | BOOLEAN | 启用后,将在执行命令之前执行屏幕的新读取,以识别新元素并更新屏幕高速缓存。要正确运行命令,必须进行此识别,以防屏幕上有任何更改。 |
| -- 标识 | 标识 | 仅当“选择器”为“标识”或“标识和名称”时 | 文本 | 从中获取信息的控件标识。 |
| -- 名称 | 名称 | 仅当“选择器”为“名称”、“名称和值”、“标识和名称”或“类型和名称”时 | 文本 | 从中获取信息的控件的名称。 |
| --innertext | 文本 | 仅当“选择器”为“内部文本和标记”时 | 文本 | 控件的内部文本。 |
| --tagname | 元素类型 | 仅当“选择器”为“内部文本和标记”时 | 文本 | 从中获取控件信息的元素的类型。 |
| --xpath | XPath | 仅当“选择器”为“XPath”时 | 文本 | 将转至从中获取信息的控件的 XPath。 |
| --classname | 类 | 仅当“选择器”为“类和值”或“类名”时 | 文本 | 从中获取信息的控件类。 |
| --elementvalue | 元素值 | 仅当“选择器”为“类和值”或“名称和值”时 | 文本 | 从中获取控件信息的元素的值。 |
| --controltype | 类型 | 仅当“选择器”为“类型和索引”或“类型和名称”时 | ControlTypes | 从中获取信息的控件的类型。 |
| -- 索引 | 索引 | 仅当“选择器”为“类型和索引”时 | 成员 | 从中获取信息的控件的索引。 |
| --control | 控件 | 仅当“选择器”为“实例”时 | 控件 | 控件实例。使用搜索控件命令获取此变量。 |
| --usetable | 表中的元素 | 可选 | BOOLEAN | 启用后,将可以按列或行在表中查找元素。 |
| --searchbycolumn | 按列搜索 | 可选 | BOOLEAN | 按列而不是行在表中搜索元素。 |
| --searchcolumn | 列 | 仅当“表中的元素”为 True 时 | 文本 | 要获取元素的列的名称或值。 |
| --searchvalue | 值 | 仅当“按列搜索”为 True 时 | 文本 | 用于在表中查找元素的值。 |
| --returncolumn | 返回列 | 仅当“按列搜索”为 True 时 | 文本 | 包含控件的列。 |
| --row | 行 | 仅当“按列搜索”为 False 时 | 成员 | 将查找元素的表行。 |
| --timeout | Timeout | 可选 | 时间范围、数字、文本 | 执行命令的最长时间限制。如果没有为超时参数定义任何值,那么执行将使用设置超时命令所定义的上下文超时。 如果脚本中未使用该命令,那么缺省超时为 5 秒。 |
输出
| 脚本 | 设计器 | AcceptedTypes | Description |
|---|---|---|---|
| 控制 | 控件 | 控件 | 返回控件的实例。 |
| bounds | 边界 | 矩形 | 返回控件边界。 |
| 句柄 | 句柄 | 成员 | 返回控件句柄。句柄是窗口的标识。 |
| 类 | 类 | 文本 | 返回控件的类。 |
示例
使用启动并附加窗口命令打开“记事本”窗口并将其与执行上下文关联。 使用获取控件命令从此窗口获取控件信息。最后,使用记录消息记录在 IBM RPA Studio 控制台中获取的信息。
defVar --name limits --type Rectangle
defVar --name windowId --type Numeric
defVar --name class --type String
defVar --name window --type Window
launchWindow --executablepath "notepad.exe" --timeout 00:00:10 window=value
getControl --selector "XPath" --xpath "/root" class=class windowId=handle limits=bounds
logMessage --message "Limits: ${limits}\r\nClass: ${class}\r\nHandle: ${windowId}" --type "Info"
// Opens and associates a Notepad window with the execution context, obtains its control information and registers it in the console.
备注
可以使用 IBM RPA Studio的记录器来获取以下信息: