DarkB1ade Posted September 30, 2012 Share Posted September 30, 2012 (edited) I`m trying to make a larger script which involves asking the user to input a path and saving it to an ini file. In another part of the script i am asking for other information (delivered through a Inputbox) and it works without problem. Also the open file dialg works since writing the path to a file (not ini, but .txt) works flawlessly. Here is my code Local $message = "Select your executable" Local $file = FileOpen("path.txt", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf Local $path = FileOpenDialog($message, "C:" & "", "Select the executable (*.exe)", 1 + 4) If @error Then MsgBox(4096, "", "No File(s) chosen") Else $path = StringReplace($path, "|", @CRLF) MsgBox(4096, "", "You chose " & $path) IniWrite("appini.ini", "details", "$path", $path) FileWrite($file, $path) EndIf As u can see the FileWrite works great, but the Iniwrite does nothing Any assistance will be greatly apriciated Edited September 30, 2012 by DarkB1ade Link to comment Share on other sites More sharing options...
water Posted September 30, 2012 Share Posted September 30, 2012 (edited) Welcome to AutoIt and the forum! I just tried this little reproducer and it works fine: $path = "C:temptest file1.xls" & @CRLF & "C:temptest file2.xls" Global $iResult = IniWrite("appini.ini", "details", "$path", $path) ConsoleWrite($iResult & " " & @error & @LF)But IniRead can't handle multiline values. You have to save the files the user selected with the "|" character. Edited September 30, 2012 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 30, 2012 Moderators Share Posted September 30, 2012 DarkB1ade,The problem is that, as it explains in the Help file for FileOpenDialog:"@WorkingDir is changed on successful return"So you are trying to create the ini file in the same folder as the file you select. Just use FileChangeDir to change it back (to @ScriptDir perhaps?) before you write the ini file. M23 FireFox 1 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...
FireFox Posted September 30, 2012 Share Posted September 30, 2012 (edited) @Melba23So tell me why if you change this : Local $path = FileOpenDialog($message, "C:\", "Select the executable (*.exe)", 1 + 4) to this : Local $path = FileOpenDialog($message, "C:\", "Images (*.jpg;*.bmp)", 1 + 4) It works...Edit : Forget, I was choosing the Image in the same folder as the script Br, FireFox. Edited September 30, 2012 by FireFox Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 30, 2012 Moderators Share Posted September 30, 2012 FireFox,Your "fix" does not for work for me. If I select a file using FileOpenDialog the @WorkingDir is always changed to the folder of the selected file - regardless of the type of file chosen. Then any non-path-specified file is saved in that folder - until @WorkingDir is changed again.Are you actually selecting one of the image files when you run that code? Because if you merely cancel the dialog, @WorkingDir is not changed. 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...
FireFox Posted September 30, 2012 Share Posted September 30, 2012 @Melba23 Yes, I edited my post to tell that I was wrong. I was testing the script on my desktop and I was selecting shortcuts (on the desktop) that linked to exes, so I was confused about the directory when choosing images on the desktop. Thanks anyway for the tip, I did not know that. Br, FireFox. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 30, 2012 Moderators Share Posted September 30, 2012 FireFox, No problem. DarkB1ade, All clear? 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...
DarkB1ade Posted September 30, 2012 Author Share Posted September 30, 2012 Yes, thank you very much for the quick answers. That did the trick Melba23. I was actually deep in thought about another part of the script and didn`t realise i already had 4 answers:) Thanks again for the promptness Link to comment Share on other sites More sharing options...
DarkB1ade Posted September 30, 2012 Author Share Posted September 30, 2012 I`m not sure i was clear enough, so for other people in the future having this problem, the fix is this: IniWrite(@scriptDir & "appini.ini", "details", "$path", $path) @water, my problem wasn`t multiple files selected. I only ever need 1 to be selected. But thanks for the warm welcome guys Link to comment Share on other sites More sharing options...
water Posted September 30, 2012 Share Posted September 30, 2012 But your code allows "MultiSelect" and handles the pipe character "|". To remove "MultiSelect" remove the "+ 4" in the FileOpenDialog statement. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
DarkB1ade Posted September 30, 2012 Author Share Posted September 30, 2012 (edited) Ah, sorry for the tripple post, but it seems i can`t edit my own posts. I realised i needed to write some other things to the same ini file later on so instead of mentioning the path every time i just took your advice and changed the working dir back to the script dir FileChangeDir (@Scriptdir) Thanks again @water thanks for the heads up i copied that part from an older script didn`t realise i let the multiselect part live. Fixed Edited September 30, 2012 by DarkB1ade Link to comment Share on other sites More sharing options...
water Posted September 30, 2012 Share Posted September 30, 2012 IIRC you have to have at least a post count of 5 before you can edit a post. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki 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