darkleton Posted September 28, 2010 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
wakillon Posted September 28, 2010 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.18.0 X86 - SciTE 4.4.6.0 - WIN 11 24H2 X64 - Other Examples Scripts
darkleton Posted September 28, 2010 Author 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.
wakillon Posted September 28, 2010 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.18.0 X86 - SciTE 4.4.6.0 - WIN 11 24H2 X64 - Other Examples Scripts
wolf9228 Posted September 28, 2010 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 صرح السماء كان هنا
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now