awangn6600 Posted January 21, 2013 Posted January 21, 2013 (edited) hello guys, i'm new at autoit scripting. i used to code in VB6, after i found autoit, i'm started to think that autoit is easier to use now i'm facing some problem, i was trying to save a directory path into an ini files (via IniWrite function). But i find out that the path is not saved to files. I'm trying to figuing out what was the problem, and i think the ':' was the problem. Because when i delete the ':', the path saved successfully. here's my code: Func InitSettings() if not FileExists("settings.ini") then IniWrite ( "settings.ini", "section", "key", "value" ) Else $BBoy = iniread("settings.ini", "Settings", "BBoy","") $PF = iniread("settings.ini", "Settings", "PF","") $audi = iniread("settings.ini", "Settings", "Audi","") $pass = iniread("settings.ini", "Start", "Pass","") $d1 = iniread("settings.ini", "Settings", "Delay1","") $d2 = iniread("settings.ini", "Settings", "Delay2","") $AutoLogon = iniread("settings.ini", "Start", "AutoLogon","") GUICtrlSetData($Input1, $BBoy) GUICtrlSetData($Input2, $PF) GUICtrlSetData($Input3, $audi) GUICtrlSetData($Input4, $pass) GUICtrlSetData($Input5, $d1) GUICtrlSetState($Checkbox1, $AutoLogon) EndIf EndFunc Func SaveSettings() $BBoy = GUICtrlRead($Input1) $PF = GUICtrlRead($Input2) $audi = GUICtrlRead($Input3) $pass = GUICtrlRead($Input4) $d1 = GUICtrlRead($Input5) $d2 = GUICtrlRead($Input6) $AutoLogon = GUICtrlRead($Checkbox1) iniwrite("settings.ini", "Settings", "BBoy", $BBoy) iniwrite("settings.ini", "Settings", "PF", $PF) iniwrite("settings.ini", "Settings", "Audi", $audi) iniwrite("settings.ini", "Start", "Pass", $pass) iniwrite("settings.ini", "Settings", "Delay1", $d1) iniwrite("settings.ini", "Settings", "Delay2", $d2) iniwrite("settings.ini", "Start", "AutoLogon", $AutoLogon) EndFunc the paths are $Input1, $Input2, $Input3 everything is saved perfectly except that. thank you for reading , and sorry for my terrible english --------- edit: i think ':' doesn't cause the problem. the problem is come from Case $Button4 $File = FileOpenDialog ("Browse for BBoy Cheat...", "", "Executable file (*.exe)", 1+4) GUICtrlSetData($Input1, $File) i assign $Input1 value from FileOpenDialog, and then i try to save with $BBoy = GUICtrlRead($Input1) iniwrite("settings.ini", "Settings", "BBoy", $BBoy) and doesnt work. But when i enter some path directly to the $Input1, the saving method above works. dunno where's my fault, so please help me Edited January 21, 2013 by awangn6600
Moderators Melba23 Posted January 21, 2013 Moderators Posted January 21, 2013 awangn6600,Welcome to the Autoit forum. Using FileOpenDialog changes the working folder when you use it - so as you do not specify a path when you write to the ini file, the file is created in whichever folder you selected with FileOpenDialog.There are 2 solutions available to you:- 1. Reset the working folder to the script folder once you have used FileOpenDialog:FileChangeDir(@ScriptDir)- 2. Use a full path for the IniWrite file:IniWrite(@ScriptDir & "\settings.ini", "Settings", .....)All clear? M23P.S. I see that you are writing a script which loads game cheats. Please read the Forum rules (there is also a link at bottom right of each page) and note that we do not support such scripts. This thread will now be locked. Please do not ask for any more help with this script - or any others which go against the forum rules. You only got the above because the learning point is one worth making to a wider audience and you have not got very far with your script. 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: Reveal hidden contents 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
Recommended Posts