对保存文件对话框进行处理
通过将文件保存在目录中来处理保存文件对话框。
脚本语法
IBM RPA 的专有脚本语言的语法与其他编程语言类似。 该脚本语法在脚本文件中定义命令的语法。 您可以在 IBM RPA Studio的 脚本 方式下使用此语法。
handleSaveFileDialog --filepath(String) [--useregex(Boolean)] [--title(String)] --regexPattern(String) [--regexOptions(DisplayableRegexOptions)] [--id(String)] [--processid(Numeric)] [--processname(String)] [--byparent(Boolean)] [--window(Window)] [--safesearch(Boolean)] [--timeout(TimeSpan)] (Window)=value (Numeric)=processId (Boolean)=success
输入参数
下表显示了此命令中提供的输入参数的列表。 在表中,您可以看到在 IBM RPA Studio的脚本方式及其 Designer 方式等效标签中工作时的参数名称。
| 设计器方式标签 | 脚本方式名称 | 必需的 | 接受的变量类型 | 描述 |
|---|---|---|---|---|
| 文件路径 | filepath |
Required |
Text |
保存文件的完整路径。 它必须包含目录,文件名和扩展名。 例如: Desktop/File.txt.要在文件名中使用特定字符,必须遵循 发送密钥 🡥 规则。 |
| 使用正则表达式 | useregex |
Optional |
Boolean |
启用以使用正则表达式来查找保存文件对话框。 |
| 标题 | title |
Optional |
Text |
保存文件对话框的标题。 |
| 正则表达式 | regexpattern |
Only when User Regular Expression is True |
Text |
用于标识保存文件对话框的正则表达式。 |
| 选项 | regexoptions |
Optional |
DisplayableRegexOptions |
正则表达式匹配的选项。 请参阅 regexoptions 参数选项。 |
| 标识 | id |
Optional |
Text |
要处理的保存文件对话框的标识。 |
| 进程标识 | processid |
Optional |
Number |
保存文件对话框所属进程的标识。 |
| 进程名称 | processname |
Optional |
Text |
保存文件对话框所属的进程的名称。 |
| 搜索关联窗口 | byparent |
Optional |
Boolean |
启用以在附加到执行上下文的窗口中搜索子窗口。 |
| 窗口 | window |
Optional |
Window |
在其中搜索子窗口的主窗口。 |
| 安全搜索 | safesearch |
Optional |
Boolean |
启用以使用更快的算法来搜索窗口。 |
| Timeout | timeout |
Optional |
Time Span, Number, Text |
最长响应时间。 缺省时间为 5 秒。 您可以使用 设置超时 ( setTimeout) 命令来定义其他值。 |
regexOptions 参数选项
下表显示了可用于 regexOptions 输入参数的选项。 该表显示了在脚本方式下工作时的可用选项以及在设计器方式下的等效标签。
| 设计器方式标签 | 脚本方式名称 | 描述 |
|---|---|---|
| 已编译 | Compiled |
编译正则表达式而不是解释。 |
| 区域固定格式 | CultureInvariant |
忽略语言上的文化差异。 |
| ECMA 脚本 | ECMAScript |
解释 ECMA 脚本表达式。 |
| 忽略大小写 | IgnoreCase |
不区分大小写的搜索。 |
| 显式捕获 | ExplicitCapture |
唯一有效的捕获是格式为?<name> subexpression的显式命名或编号的组。 |
| 忽略模式空格 | IgnorePatternWhitespace |
忽略空格字符,并在数字符号 (#) 后启用注释。 |
| 从右到左 | RightToLeft |
从右到左或从最后到第一个读取正则表达式。 |
| 单行 | Singleline |
更改点 (.) 的含义,它与除 以外的每个字符匹配。 |
| 多行 | Multiline |
允许音调符号 (^) 和美元符号 ($) 与换行符匹配。 |
输出参数
| 设计器方式标签 | 脚本方式名称 | 接受的变量类型 | 描述 |
|---|---|---|---|
| 保存文件对话框 | value |
Window |
返回找到的保存文件对话框。 |
| 进程标识 | processid |
Number |
返回保存文件对话框的进程标识。 |
| 成功 | success |
Boolean |
如果正确处理了文件,那么返回 True 。 否则,返回 False。 |
示例
示例 1:此命令处理与在桌面上保存“记事本”文件的操作对应的对话框。
defVar --name window --type Window
defVar --name processId --type Numeric
defVar --name desktopPath --type String
launchWindow --executablepath "notepad.exe" window=value processId=processId
clickOnMenu --window ${window} --menupath "file\r\nsave"
getSpecialFolder --folder "Desktop" desktopPath=value
handleSaveFileDialog --filepath "${desktopPath}\\File.txt" --title "Save As"
logMessage --message "End\r\nFile path: ${desktopPath}\\File.txt" --type "Info""
示例 2: 此示例使用键盘快捷键来激活要处理的对话框,并使用正则表达式来查找所述对话框。
defVar --name window --type Window
defVar --name processId --type Numeric
defVar --name desktopPath --type String
launchWindow --executablepath "notepad.exe" window=value processId=processId
keyboard --type "KeyPress" --key "ControlKey"
keyboard --type "KeyDown" --key "S"
keyboard --type "KeyUp" --key "ControlKey"
getSpecialFolder --folder "Desktop" desktopPath=value
handleSaveFileDialog --filepath "${desktopPath}\\File.txt" --useregex --regexPattern "(Sa?v?e?)" --regexOptions "IgnoreCase, Multiline" --byparent
// handle the Dialog Box and save the file on the Desktop.
logMessage --message "\r\nFile path: ${desktopPath}\\File.txt" --type "Info"