Handle Save File Dialog

Handles a save file dialog box by saving the file in a directory.

Script syntax

IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.

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

Input parameter

The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
File path filepath Required Text Full path to save the file. It must include the directory, file name, and extension. For example: Desktop/File.txt.

To use specific characters in the file name, you must follow the Send Keys 🡥 rules.
Use Regular Expression useregex Optional Boolean Enable to use regular expressions to find the save file dialog box.
Title title Optional Text Title of the save file dialog box.
Regular Expression regexpattern Only when User Regular Expression is True Text Regular expression used to identify the save file dialog box.
Options regexoptions Optional DisplayableRegexOptions Options for regular expression matching.

See the regexoptions parameter options.
Identifier id Optional Text Id of the save file dialog box to be handled.
Process Id processid Optional Number Id of the process the save file dialog box belongs to.
Process Name processname Optional Text Name of the process the save file dialog box belongs to.
Search Associated Window byparent Optional Boolean Enable to search for child windows inside the window that is attached to the execution context.
Window window Optional Window Main window in which the child windows are searched.
Safe Search safesearch Optional Boolean Enable to search for the window by using a faster algorithm.
Timeout timeout Optional Time Span, Number, Text Maximum response time. The default time is 5 seconds.

You can define a different value by using the Set Timeout (setTimeout) command.

regexOptions parameter options

The following table displays the options available for the regexOptions input parameter. The table shows the options available when working in Script mode and the equivalent label in the Designer mode.

Designer mode label Script mode name Description
Compiled Compiled Compiles regex expressions instead of interpreting.
Culture Invariant CultureInvariant Ignores cultural differences in language.
ECMA Script ECMAScript Interprets ECMA Script expressions.
Ignore Case IgnoreCase Case-insensitive search.
Explicit Capture ExplicitCapture The only valid captures are explicitly named or numbered groups of the form (?<name> subexpression).
Ignore Pattern Whitespace IgnorePatternWhitespace Ignores whitespace characters, and enables comments after a number sign (#).
Right To Left RightToLeft Reads regex expressions from right to left, or from last to first.
Singleline Singleline Changes the meaning of the dot (.), which matches every character except .
Multiline Multiline Allows the circumflex (^) and dollar sign ($) symbols to match newline characters.

Output parameter

Designer mode label Script mode name Accepted variable types Description
Save file dialog box value Window Returns the save file dialog box found.
Process Id processid Number Returns the process Id of the save file dialog box.
Success success Boolean Returns True if the file was properly handled. Otherwise, returns False.

Example

Example 1: The command handles a dialog box that corresponds to the action of saving the Notepad file on the desktop.

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""

Example 2: This example uses keyboard shortcuts to activate the dialog box to be handled and a regular expression to find said dialog box.

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"