控件屏幕快照
动词:printControl
可从以下位置获取: <Standard>
使用选择器识别所需控件,以获取用户界面控件的屏幕快照。
在 Windows 上下文中,控件是允许用户与应用程序进行交互的元素。 控件可以是按钮、数据输入字段、菜单和各种其他元素。
语法
printControl [--rectangle(Rectangle)] --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)] (Image)=value
输入
| 脚本 | 设计器 | 必需的 | AcceptedTypes | Description |
|---|---|---|---|---|
| --rectangle | 区域 (Area) | 可选 | 矩形 | 在屏幕上定界一个区域以获取屏幕快照。 |
| --selector | 选择器 | 必需的 | ControlSelectors | 用于识别用户界面控件的选择器的类型。 提供了以下选项:
|
| -- 标识 | 标识 | 仅当“选择器”为“标识”或“标识和名称”时 | 文本 | 应获取其屏幕快照的控件的标识。 |
| -- 名称 | 名称 | 仅当“选择器”为“名称”、“名称和值”、“标识和名称”或“类型和名称”时 | 文本 | 应获取其屏幕快照的用户界面控件的名称。 |
| --innertext | 文本 | 仅当“选择器”为“内部文本和标记”时 | 文本 | 应获取其屏幕快照的用户界面控件的内部文本。 |
| --tagname | 元素类型 | 仅当“选择器”为“内部文本和标记”时 | 文本 | 应获取其屏幕快照的控件的元素或标记的类型。 |
| --xpath | XPath | 仅当“选择器”为“XPath”时 | 文本 | 应获取其屏幕快照的用户界面控件的 XPath。 |
| --classname | 类 | 仅当“选择器”为“类和值”或“类名”时 | 文本 | 应获取其屏幕快照的用户界面控件的类。 |
| --elementvalue | 元素值 | 仅当“选择器”为“类和值”或“名称和值”时 | 文本 | 应获取其屏幕快照的用户界面控件的当前值。 |
| --controltype | 类型 | 仅当“选择器”为“类型和索引”或“类型和名称”时 | ControlTypes | 用户界面控件的类型。 选项: |
| -- 索引 | 索引 | 仅当“选择器”为“类型和索引”时 | 成员 | 用户界面控件的索引。 |
| --control | 控件 | 仅当“选择器”为“实例”时 | 控件 | 控件实例。使用命令搜索控件获取此变量。 |
| --usetable | 表中的元素 | 可选 | BOOLEAN | 启用后,将在表中搜索元素。 |
| --searchbycolumn | 按列搜索 | 可选 | BOOLEAN | 启用后,将按列而不是行搜索元素。 |
| --searchcolumn | 列 | 仅当“表中的元素”为 True 时 | 文本 | 从中获取元素的列的名称或编号。 |
| --searchvalue | 值 | 仅当“按列搜索”为 True 时 | 文本 | 用于在表中查找元素的值。 |
| --returncolumn | 返回列 | 仅当“按列搜索”为 True 时 | 文本 | 包含控件的列。 |
| --row | 行 | 仅当“按列搜索”为 False 时 | 成员 | 从中获取元素的表行。 |
| --timeout | 超时 | 可选 | 时间范围、数字、文本 | 命令执行超时。如果没有为超时参数定义任何值,那么执行将使用设置超时命令所定义的上下文超时。 如果脚本中未使用该命令,那么缺省超时为 5 秒。 |
输出
| 脚本 | 设计器 | AcceptedTypes | Description |
|---|---|---|---|
| 值 | Image | 图像 | 获取的屏幕快照图像。 |
示例
使用控件屏幕快照命令,获取“记事本”文本框的屏幕快照,同时使用文本框标识对其进行识别。 然后,会在桌面上保存图像。
defVar --name desktopPath --type String
defVar --name image --type Image
getSpecialFolder --folder "Desktop" desktopPath=value
// Opens a Notepad window.
launchWindow --executablepath "notepad.exe"
// Takes a screenshot of the text box.
printControl --selector "Id" --id 15 image=value
// Save the image obtained in the work area.
saveImage --image ${image} --directory "${desktopPath}" --file "Control image capture" --format "Png"
备注
可以使用 IBM RPA Studio的记录器来获取以下信息: