Vanberk Posted June 6, 2009 Share Posted June 6, 2009 Argh.. have been fighting whole night to get it to work! I want the IniWriteSection(@scriptdir & "\Test.ini", $gSel, "-=" & $inputbox2) to write a NEW line under the already existing keys in the section.The text I type in the $inputbox2 get in the right section, but it overwrite all the other keys that where inside the section...expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiTreeView.au3> #include <WindowsConstants.au3> #Include <GuiButton.au3> Opt('MustDeclareVars', 1) Main() Func Main() Local $hItem, $hTreeView, $btn1, $btn2, $btn3, $FileList1, $FileList2, $inputbox, $inputbox2, $gSel, $iRead Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES) GUICreate("AutoIt", 450, 450) $hTreeView = GUICtrlCreateTreeView(10, 40, 430, 300, $iStyle, $WS_EX_CLIENTEDGE) GUISetState() $btn1 = GUICtrlCreateButton("New", 360, 350, 80, 30) $btn2 = GUICtrlCreateButton("Add", 360, 380, 80, 30) $btn3 = GUICtrlCreateButton("Delete", 360, 410, 80, 30) $FileList1 = IniReadSectionNames(@scriptdir & "\Test.ini") _GUICtrlTreeView_BeginUpdate($hTreeView) For $x = 2 To $FileList1[0] $FileList2 = Inireadsection(@scriptdir & "\Test.ini", $FileList1[$x]) $hItem = _GUICtrlTreeView_Add($hTreeView, 0, $FileList1[$x], $x) For $y = 1 to $FileList2[0][0] _GUICtrlTreeView_AddChild($hTreeView, $hItem, $FileList2[$y][1], $y) Next Next _GUICtrlTreeView_AddFirst($hTreeView, $hItem, "AutoIt") _GUICtrlTreeView_EndUpdate($hTreeView) Do if GUIGetMsg() = $btn1 Then $inputbox = Inputbox("New", "Enter addon name","","",300,120) $inputbox2 = inputbox("New", "Enter file location","","",300,120) _GUICtrlTreeView_BeginUpdate($hTreeView) $hItem = _GUICtrlTreeView_Add($hTreeView, 0, $inputbox, $x) _GUICtrlTreeView_AddChild($hTreeView, $hItem, $inputbox2, $y) Iniwritesection(@scriptdir & "\Test.ini", $inputbox, "-=" & $inputbox2) _GUICtrlTreeView_EndUpdate($hTreeView) EndIf if GUIGetMSG() = $btn2 Then $inputbox2 = inputbox("New", "Enter file location", "", "", 300, 120) $gSel = _GUICtrlTreeView_GetTree($hTreeView, $hItem) _GUICtrlTreeView_AddChild($hTreeView, $hItem, $inputbox2, $y) $iRead = IniReadSection(@scriptdir & "\Test.ini", $gSel) IniWriteSection(@scriptdir & "\Test.ini", $gSel, "-=" & $inputbox2) EndIf Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc Link to comment Share on other sites More sharing options...
Mat Posted June 6, 2009 Share Posted June 6, 2009 (edited) I don't quite understand exactly what your getng at, but you want iniwrite not iniwritesection don't you? MDiesel iniWrite (@ScriptDir & "\test.ini, $gSel, $InputBox2) Edited June 6, 2009 by mdiesel AutoIt Project Listing Link to comment Share on other sites More sharing options...
Vanberk Posted June 6, 2009 Author Share Posted June 6, 2009 (edited) I changed it to:if GUIGetMSG() = $btn2 Then $inputbox2 = inputbox("New", "Enter file location", "", "", 300, 120) $gSel = _GUICtrlTreeView_GetTree($hTreeView, $hItem) $gSel2 = _GUICtrlTreeView_GetSelection($hTreeView) _GUICtrlTreeView_AddChild($hTreeView, $gSel, $inputbox2, $y) msgbox(0, "", $gSel & " " & $gSel2) $iRead = IniReadSection(@scriptdir & "\Test.ini", $gSel) $y = $y + 1 iniWrite(@ScriptDir & "\test.ini", $gSel, $y, $InputBox2) EndIf It works fine now, but i still have problem with one thing... How can I get the name of the section i have selected in the Treeview? Edited June 6, 2009 by Vanberk Link to comment Share on other sites More sharing options...
Mat Posted June 6, 2009 Share Posted June 6, 2009 GUICtrlRead ($hTreeView, 1) Is that what you mean? MDiesel AutoIt Project Listing Link to comment Share on other sites More sharing options...
Vanberk Posted June 6, 2009 Author Share Posted June 6, 2009 GUICtrlRead ($hTreeView, 1) Is that what you mean? MDieselSweet that worked, thanks alot! oh, Is there some tutorials for these things or is it just for the more basic stuff? Link to comment Share on other sites More sharing options...
Mat Posted June 6, 2009 Share Posted June 6, 2009 no, i don't think so... but the helpfile is the best place to look, between the helpfile and testing, you should be able to work out most things.After a while it becomes easier, once you get a general idea of where to look! eg, for your second questionm I knew i needed GUICtrlRead, after looking at the helpfile under that section I found this: TreeView The text of the current selected TreeViewItem. under advanced. after testing and finding out it worked, i posted. simple!!MDiesel AutoIt Project Listing 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