获取图像网格
动词:getGrid
❕ 重要信息: 从 V 23.0.6开始,不推荐使用此命令。 有关更多信息,请参阅 不推荐。
获取由图像表示的控件网格。
在 Windows 上下文中,控件是允许用户与应用程序进行交互的元素。 控件可以是按钮、数据输入字段、菜单和各种其他元素。
语法
getGrid [--hascolumnheaders(Boolean)] [--hasrowheaders(Boolean)] [--hasbandrows(Boolean)] [--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)] (ImageGrid)=value (Numeric)=rows (Numeric)=columns
输入
| 脚本 | 设计器 | 必需的 | AcceptedTypes | 描述 |
|---|---|---|---|---|
| --hascolumnheaders | 列标题 | 可选 | BOOLEAN | 启用后,将考虑网格列中的标题。 |
| --hasrowheaders | 行标题 | 可选 | BOOLEAN | 启用后,将考虑网格行中的标题。 |
| --hasbandrows | 条纹行 | 可选 | BOOLEAN | 当行具有交替背景色时,必须启用此功能。 |
| --forcerefresh | 更新屏幕高速缓存 | 可选 | BOOLEAN | 启用后,将在执行命令之前执行屏幕的新读取,以识别新元素并更新屏幕高速缓存。要正确运行命令,必须进行此识别,以防屏幕上有任何更改。 |
| --selector | 选择器 | 必需的 | ControlSelectors | 用于识别用户界面控件的选择器的类型。 提供了以下选项:
|
| --id | 标识 | 仅当“选择器”为“标识”或“标识和名称”时 | 文本 | 从中获取网格的控件的标识。 |
| --name | 名称 | 仅当“选择器”为“名称”、“名称和值”、“标识和名称”或“类型和名称”时 | 文本 | 从中获取网格的控件的名称。 |
| --innertext | 文本 | 仅当“选择器”为“内部文本和标记”时 | 文本 | 从中获取网格的控件的内部文本。 |
| --tagname | 元素类型 | 仅当“选择器”为“内部文本和标记”时 | 文本 | 从中获取网格的元素的类型。 |
| --xpath | XPath | 仅当“选择器”为“XPath”时 | 文本 | 将转至从中获取网格的控件的 XPath。 |
| --classname | 类 | 仅当“选择器”为“类和值”或“类名”时 | 文本 | 从中获取网格的控件的类。 |
| --elementvalue | 元素值 | 仅当“选择器”为“类和值”或“名称和值”时 | 文本 | 从中获取网格的元素的值。 |
| --controltype | 类型 | 仅当“选择器”为“类型和索引”或“类型和名称”时 | ControlTypes | 从中获取网格的控件的类型。 提供了以下选项: |
| --index | 索引 | 仅当“选择器”为“类型和索引”时 | 成员 | 从中获取网格的控件的索引。 |
| --control | 控制 | 仅当“选择器”为“实例”时 | 控件 | 控件实例。使用命令搜索控件获取此变量。 |
| --usetable | 表中的元素 | 可选 | BOOLEAN | 启用后,将按列或行在表中搜索元素。 |
| --searchbycolumn | 按列搜索 | 可选 | BOOLEAN | 启用后,将按列而不是行在表中搜索元素。 |
| --searchcolumn | 列 | 仅当“表中的元素”为 True 时 | 文本 | 将从中获取元素的列的名称或编号。 |
| --searchvalue | 值 | 仅当“按列搜索”为 True 时 | 文本 | 用于在表中查找元素的值。 |
| --returncolumn | 返回列 | 仅当“按列搜索”为 True 时 | 文本 | 包含控件的列。 |
| --row | 行 | 仅当“按列搜索”为 False 时 | 成员 | 将查找元素的表行。 |
| --timeout | Timeout | 可选 | 时间范围、数字、文本 | 命令执行超时。如果没有为超时参数定义任何值,那么执行将使用设置超时命令所定义的上下文超时。 如果脚本中未使用该命令,那么缺省超时为 5 秒。 |
输出
| 脚本 | 设计器 | AcceptedTypes | 描述 |
|---|---|---|---|
| 值 | 网格 | 图像网格 | 返回获取的网格。 |
| 行 | 行 | 成员 | 返回获取的网格中的行数。 |
| columns | 列 | 成员 | 返回获取的网格中的列数。 |
示例
使用启动或附加窗口命令打开“MS 画图”窗口,使用获取图像网格命令从颜色选择网格获取图像网格。 获取的网格的行数和列数显示在 IBM RPA Studio 控制台中。
defVar --name mappedGrid --type ImageGrid
defVar --name rows --type Numeric
defVar --name columns --type Numeric
launchOrAttach --executablepath "mspaint.exe" --useregex --regexPattern "Untitled - Paint" --regexOptions "0"
getGrid --selector "XPath" --xpath "/root/pane[3]/pane[1]/pane[1]/pane[1]/pane[1]/pane[1]/custom[1]/custom[1]/toolbar[1]/group[1]" columns=columns rows=rows mappedGrid=value
logMessage --message "Rows: ${rows}\r\n Columns: ${columns}" --type "Info"
// Returns the number of rows and columns of the gotten grid.
备注
可以使用 IBM RPA Studio的记录器来获取以下信息:
此命令获取图像并自动映射网格。 它不允许您手动映射控件网格。