Helixanon Posted December 26, 2016 Share Posted December 26, 2016 (edited) Hello. Here's the code. $pathToConfig = IniRead("settings.ini", "General", "PathToConfig", "") If Not FileExists($pathToConfig) Then TrayTip("Script", "Please point me to config file.", 5) $newPath = FileOpenDialog("Script", @ScriptDir, "Config files (*.cfg)", 1) IniWrite("settings.ini", "General", "PathToConfig", $newPath) $pathToConfig = $newPath EndIf So IniWrite with $newPath gets ignored for some reason. It returns 1, which means success, but still strange. I tried using some random strings instead of $newPath, for example "test1235", but still no success. But the most interesting thing is that IniWrite works when used before IniRead. That is, it gets updated both in NP++ and via the code. Additional info: I have 3 more IniReads above $pathToConfig line; Sometimes the value just doesn't change in .ini file, and sometimes (1 case of like 10) it becomes blank (when used after IniRead). Would appreciate any help. Edited December 26, 2016 by Helixanon Link to comment Share on other sites More sharing options...
JohnOne Posted December 26, 2016 Share Posted December 26, 2016 That code, nad only that code, does not work? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Helixanon Posted December 26, 2016 Author Share Posted December 26, 2016 Yup, .ini doesn't get updated although IniWrite returns 1. I suppose the .ini file may be busy by IniRead or something? I tried to look for any command to release the .ini file handle (like File.Close()), but there seems to be none. Link to comment Share on other sites More sharing options...
jguinch Posted December 26, 2016 Share Posted December 26, 2016 Try to specify the full path of the ini file : IniWrite(@ScriptDir & "\settings.ini", "General", "PathToConfig", $newPath) zkenjiz and Helixanon 2 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Helixanon Posted December 26, 2016 Author Share Posted December 26, 2016 Same result. Returns 1 and .ini didn't get updated. Link to comment Share on other sites More sharing options...
Helixanon Posted December 26, 2016 Author Share Posted December 26, 2016 Oh wow wait. I actually didn't notice the "\" sign you've put. I typed it and for some reason it did, indeed, update the file. So uhm, why was it needed to insert the scriptDir and put the backslash? Shouldn't it be working with non-absolute path? Anyway, the issue is solved, and I thank you. Link to comment Share on other sites More sharing options...
jguinch Posted December 26, 2016 Share Posted December 26, 2016 It depends of the working directory. Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Helixanon Posted December 26, 2016 Author Share Posted December 26, 2016 (edited) Well the .ini file is in the same folder as the script itself. Why did IniRead work this way? What exactly caused Write not to work? I'm just curious, bare with me Edited December 26, 2016 by Helixanon Link to comment Share on other sites More sharing options...
JohnOne Posted December 26, 2016 Share Posted December 26, 2016 There is nothing apparent which should cause that code to not work, especially if it returns 1, and is why I suspect there is more code at play since the code supplied does not test it. But perhaps the help file is wrong and it does require full path. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
careca Posted December 26, 2016 Share Posted December 26, 2016 The post #1 code worked here as is. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 26, 2016 Moderators Share Posted December 26, 2016 Helixanon, I think the reason behind the problem lies in this section of the Help file (my bold): Quote The working directory is set to @ScriptDir at script start and this path can be altered during the running of the script by calling FileChangeDir. But note that the current working directory can be also be changed automatically by some functions - e.g. FileOpen/SaveDialog on a successful return, So after a successful selection of the new path, the working directory is reset to the selected folder and so you need to specify the full path of the ini file - or reset the working folder to @ScriptDir using FileChangeDir. 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...
jguinch Posted December 26, 2016 Share Posted December 26, 2016 (edited) Ah yes, thanks Melba, you refresh my memory... I remember now this behaviour with FileOpenDialog and FileSaveDialog. I had the answer but not the explaination... Edited December 26, 2016 by jguinch Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
JohnOne Posted December 26, 2016 Share Posted December 26, 2016 I was under the impression that autoit3 checked running script location and environment path for file names. must have been thinking of just dll files. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Helixanon Posted December 27, 2016 Author Share Posted December 27, 2016 (edited) Ooooh, that's interesting. So as summary, after FileOpenDialog it tried to look for .ini file in the folder which was returned by FileOpenDialog? Funny stuff. Right, should've mentioned that the .ini file was in a same folder but I thought it was obvious Thank you. Edited December 27, 2016 by Helixanon Link to comment Share on other sites More sharing options...
JohnOne Posted December 27, 2016 Share Posted December 27, 2016 Nothing funny about it, just a little odd. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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