darkleton 0 Posted September 28, 2010 I have a script that prompts a user for a folder to use (fileselectfolder) and then uses that folder for the fileopendialog for them to select a file. what i want though is for the fileopendialog box to be restricted JUST to that folder. as it stands, fileselectfolder could have c:\test\ selected, and clicking the fileopendialog button will default to c:\test\ but allows them to move up a folder. i need it to restrict them to selecting a file only in the given folder. is that possible? These are the two functions I have which work perfectly, I just need that restriction if it can be done? Func LocalFolder() $localmsifolder = FileSelectFolder("","") GUICtrlSetData($localmsifolderinput, $localmsifolder & "\") $remotemsifolder = StringRegExpReplace($localmsifolder, "^.*\\", "") EndFunc Func LocalFile() $localmsifile = FileOpenDialog("", $localmsifolder, "MSI Files (*.msi)", 1 + 2) GUICtrlSetData($localmsifileinput, $localmsifile) $localmsifilename = StringRegExpReplace($localmsifile, "^.*\\", "") EndFunc Thanks in advance Mike Share this post Link to post Share on other sites
wakillon 403 Posted September 28, 2010 I don't think so ! but you can add a condition after select the file $_Dir = "c:\test\" Do $localmsifolder = FileOpenDialog ( "Choose the file", $_Dir, '(*.msi)' ) ConsoleWrite ( "$localmsifolder : " & $localmsifolder & @Crlf ) Until StringInStr ( $localmsifolder, $_Dir ) <> 0 AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Share this post Link to post Share on other sites
darkleton 0 Posted September 28, 2010 how would i set the $_dir variable though as the folder selected is entirely up to the user. i couldn't give it a value. Share this post Link to post Share on other sites
wakillon 403 Posted September 28, 2010 how would i set the $_dir variable though as the folder selected is entirely up to the user. i couldn't give it a value.By $_Dir = FileSelectFolder ( "", "" ) AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Share this post Link to post Share on other sites
wolf9228 65 Posted September 28, 2010 I have a script that prompts a user for a folder to use (fileselectfolder) and then uses that folder for the fileopendialog for them to select a file. what i want though is for the fileopendialog box to be restricted JUST to that folder. as it stands, fileselectfolder could have c:\test\ selected, and clicking the fileopendialog button will default to c:\test\ but allows them to move up a folder. i need it to restrict them to selecting a file only in the given folder. is that possible? These are the two functions I have which work perfectly, I just need that restriction if it can be done? Func LocalFolder() $localmsifolder = FileSelectFolder("","") GUICtrlSetData($localmsifolderinput, $localmsifolder & "\") $remotemsifolder = StringRegExpReplace($localmsifolder, "^.*\\", "") EndFunc Func LocalFile() $localmsifile = FileOpenDialog("", $localmsifolder, "MSI Files (*.msi)", 1 + 2) GUICtrlSetData($localmsifileinput, $localmsifile) $localmsifilename = StringRegExpReplace($localmsifile, "^.*\\", "") EndFunc Thanks in advance Mike _FileOpenDialog() _FileSelectFolder() Func _FileOpenDialog($DialogTitle = "DialogTitle",$defaultPath = "C:\test\",$filter = "All (*.*)",$options = 8,$defaultFilename = "defaultFilename",$Guihwnd =0) $var = FileOpenDialog ($DialogTitle,$defaultPath,$filter,$options,$defaultFilename,$Guihwnd) if Not @error Then Local $OutPath $TexArray = StringSplit($var,"\") For $i = 1 To $TexArray[0] $OutPath &= $TexArray[$i] & "\" if $i = $TexArray[0] Then $OutPath = StringTrimRight($OutPath,1) Next MsgBox(0,"MSG",$OutPath) Else if @error = 1 Then MsgBox(0,"MSG","File selection failed") if @error = 2 Then MsgBox(0,"MSG","Bad file filter ") EndIf EndFunc Func _FileSelectFolder($DialogText = "DialogText",$RootDir = "C:\",$Flag = 3, $InitialDir = "C:\test\",$Guihwnd = 0) $var = FileSelectFolder ($DialogText,$RootDir,$Flag,$InitialDir,$Guihwnd) if Not @error Then Local $OutPath $TexArray = StringSplit($var,"\") For $i = 1 To $TexArray[0] $OutPath &= $TexArray[$i] & "\" if $i = $TexArray[0] Then $OutPath = StringTrimRight($OutPath,1) Next MsgBox(0,"MSG",$OutPath) Else if @error = 1 Then MsgBox(0,"MSG","user cancels/closes the window.") EndIf EndFunc صرح السماء كان هنا Share this post Link to post Share on other sites