Initiates a Open File Dialog.
FileOpenDialog ( "title", "init dir", "filter" [, options = 0 [, "default name" [, hwnd]]] )
Separate the file filters with a semicolon as shown in the example.
Multiple groups of filters are separated by a pipe "|".
If default name is given, options must also be given. If none of the options are wanted, use 0 for options.
Special Windows folders (such as "My Documents") can be set as root by using the right CLSID detailed in the Appendix.
@WorkingDir is changed on successful return.
FileSaveDialog, FileSelectFolder, StringSplit
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
Example()
Func Example()
; Create a constant variable in Local scope of the message to display in FileOpenDialog.
Local Const $sMessage= "Hold down Ctrl or Shift to choose multiple files."
; Display an open dialog to select a list of file(s).
Local $sFileOpenDialog= FileOpenDialog ($sMessage,@WindowsDir &"\","Images (*.jpg;*.bmp)|Videos (*.avi;*.mpg)",BitOR ($FD_FILEMUSTEXIST,$FD_MULTISELECT))
If @error Then
; Display the error message.
MsgBox ($MB_SYSTEMMODAL,"","No file(s) were selected.")
; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
FileChangeDir (@ScriptDir )
Else
; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
FileChangeDir (@ScriptDir )
; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog.
$sFileOpenDialog= StringReplace ($sFileOpenDialog,"|",@CRLF )
; Display the list of selected files.
MsgBox ($MB_SYSTEMMODAL,"","You chose the following files:"&@CRLF &$sFileOpenDialog)
EndIf
EndFunc ;==>Example
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
Example()
Func Example()
; Create a constant variable in Local scope of the message to display in FileOpenDialog.
Local Const $sMessage= "Select a single file of any type."
; Display an open dialog to select a file.
Local $sFileOpenDialog= FileOpenDialog ($sMessage,@WindowsDir &"\","All (*.*)",$FD_FILEMUSTEXIST)
If @error Then
; Display the error message.
MsgBox ($MB_SYSTEMMODAL,"","No file was selected.")
; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
FileChangeDir (@ScriptDir )
Else
; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
FileChangeDir (@ScriptDir )
; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog.
$sFileOpenDialog= StringReplace ($sFileOpenDialog,"|",@CRLF )
; Display the selected file.
MsgBox ($MB_SYSTEMMODAL,"","You chose the following file:"&@CRLF &$sFileOpenDialog)
EndIf
EndFunc ;==>Example