gsbaker Posted February 17, 2011 Share Posted February 17, 2011 In the script segment below (which includes lots of MsgBox to see what is going on) I am trying to reset the working directory after successfully returning the results of a FileOpenDialog. Case $msg = $button5 ; Select Index background image $setMsg = MsgBox(0,"Test","ScriptDir = " & @ScriptDir & @CRLF & "Working Directory = " & @WorkingDir) FileChangeDir(@ScriptDir & "\Resources") $select_file = FileOpenDialog("Select Index background image from THIS FOLDER ONLY!", @ScriptDir & "\Resources", "(*.jpg;*.png;*.gif)") If $select_file <> "" Then $filelength = (@ScriptDir & "\Resources\") $scriptlen = StringLen($filelength) $filerel = StringTrimLeft($select_file,$scriptlen) GUICtrlSetData($Input[70], $filerel) EndIf $setMsg = MsgBox(0,"Test","ScriptDir = " & @ScriptDir & @CRLF & "Working Directory = " & @WorkingDir) FileChangeDir(@ScriptDir) $setMsg = MsgBox(0,"Test","ScriptDir = " & @ScriptDir & @CRLF & "Working Directory = " & @WorkingDir) While the last FileChangeDir statement seems to change the working directory back to where I want it, it does NOT change it for the next time I use FileOpenDialog - which starts in the same place as the directory from the last successful FileOpenDialog. For some reason it is not re-setting the "init dir" parameter, but is using the previous results. Am I missing something? Now can I get the FileOpenDialog to start in a specific directory (@ScriptDir) each time, and not pick up the directory from the previous result? Thanks for your assistance. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 17, 2011 Moderators Share Posted February 17, 2011 gsbaker,I cannot help with your specific problem - it looks as if it should work to me. However, I found the seemingly random behaviour of the FileOpenDialog dialog so annoying that I actually wrote my own UDF to do what I wanted and not what Windows thought I might want. Take a look at the ChooseFileFolder UDF in my sig. If you really want to limit the user to selecting files from a single folder the UDF will let you do just that - it was one of the things about the FileOpenDialog dialog that annoyed me the most! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
gsbaker Posted February 17, 2011 Author Share Posted February 17, 2011 (edited) Thanks M23. I will have a look. Stupid question? Where should I "unzip" these to?Also, it looks like this also changes the working directory. Is that correct? Check that - it appears to NOT change the working directory Edited February 17, 2011 by gsbaker Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 17, 2011 Moderators Share Posted February 17, 2011 gsbaker,I would suggest you unzip them into a folder where you normally create your scripts - they all need to be together for the example to work. If you decide to use them in other scripts then you will need to put the include files (everything except the example) somewhere where AutoIt can find them. I would not suggest putting them in with the AutoIt includes - for a start Vista/Win7 do not like you putting things into the "Program Files" folder!But you can set specific folders that AutoIt will search for #include files as well as the standard "C:\Program Files\AutoIt3\Include" - from the Help file:"There is a special registry value that can be created at "HKEY_CURRENT_USER\Software\AutoIt v3\AutoIt" called "Include". It should be a REG_SZ (string) value. The contents of this value are a semi-colon delimited list of directories that should be searched for files when resolving #include's in addition to the standard locations."If you have the full SciTE4AutoIt3 editor, you can also set this folder in SciTEConfig - look in the <Tools> menu.So you can put all your downloaded includes into a folder away from "Program Files" - and they will not be overwritten when you next update! And you can call them using the same syntax as the standard include files. this also changes the working directory. Is that correct?No - it makes no changes to anything at all. It just returns the selected file(s)/folder(s) in a "|" delimited string. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
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