获取边界
动词:getBounds
获取控件的边界。
语法
getBounds --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)] (Numeric)=top (Numeric)=bottom (Numeric)=left (Numeric)=right (Numeric)=width (Numeric)=height
输入
| 脚本 | 设计器 | 必需的 | AcceptedTypes | 描述 |
|---|---|---|---|---|
| --selector | 选择器 | 必需的 | ControlSelectors | 用于识别用户界面控件的选择器的类型。 提供了以下选项:除了在脚本中插入带有自动填充这些参数的命令外,还可以使用 IBM RPA Studio的记录器来映射控件并获取 "选择器" 参数的必要信息。 该记录器在平台上的上方工具栏中可用。 |
| --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 | 描述 |
|---|---|---|---|
| top | 上边界 | 成员 | 返回控件的上边界。 |
| bottom | 下边界 | 成员 | 返回控件的下边界。 |
| left | 左边界 | 成员 | 返回控件的左边界。 |
| right | 右边界 | 成员 | 返回控件的右边界。 |
| width | 宽度 | 成员 | 返回控件的宽度。 |
| height | 高度 | 成员 | 返回控件的高度。 |
示例
使用启动并附加窗口命令启动“记事本”窗口。 使用获取边界命令按 XPath 识别此窗口并获取其限制,同时在声明的变量中返回这些值。 命令 Log Message 显示从 IBM RPA Studio 控制台获取的值。
defVar --name topLimit --type Numeric
defVar --name bottomLimit --type Numeric
defVar --name leftLimit --type Numeric
defVar --name rightLimit --type Numeric
defVar --name width --type Numeric
defVar --name height --type Numeric
launchWindow --executablepath "notepad.exe"
getBounds --selector "XPath" --xpath "/root/titlebar[1]" --timeout 00:00:05 bottomLimit=bottom height=height leftLimit=left rightLimit=right topLimit=top width=width
logMessage --message "\r\nHeight: ${height}\r\nWidth: ${width}\r\nRight Limit: ${rightLimit}\r\nLeft Limit: ${leftLimit}\r\nBottom Limit: ${bottomLimit}\r\nTop Limit: ${topLimit}" --type "Info"
// Results may vary depending on the window size when opened, its position in the screen, among other factors
备注
可以使用 IBM RPA Studio的记录器来获取以下信息: