Aceguy Posted June 8, 2006 Share Posted June 8, 2006 when i click my save button. it doesnt save the list box. GLOBAL $info #include <GuiConstants.au3> GuiCreate("MyGUI", 191, 316,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $GO=GUICtrlCreateButton("read",5,5,60,20) $List_1 = GuiCtrlCreateList("", 40, 40, 110, 201,BitOR($WS_BORDER, $WS_VSCROLL)) $input_box= GUICtrlCreateInput("",5,230,75,30) $save=GUICtrlCreateButton("Save list",5,280,50,30) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $MSG = $GO $var = IniReadSection("c:\documents and settings\ace\desktop\recipies.ini","recipies") For $i = 1 To $var[0][0] if $var[$i][1] = $info Then MsgBox(0,"","got it") endif GUICtrlSetData($List_1,$var[$i][1]&"|") Next case $msg=$save IniWrite("c:\documents and settings\ace\desktop\recipies.ini",GUICtrlRead($List_1),GUICtrlRead($List_1),GUICtrlRead($List_1)) EndSelect WEnd Exit please help. [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 8, 2006 Moderators Share Posted June 8, 2006 3 quick things... 1. Welcome to the forums 2. Please use code tags [ code] [ /code] (without spaces) when showing code 3. recipies is recipes Now... If your going to provide some code, please make it workable, you have a var in there "$info" that has no declaration... Also IniWrite("c:\documents and settings\ace\desktop\recipies.ini",GUICtrlRead($List_1),GUICtrlRead($List_1),GUICtrlRead($List_1)) Your saving the list under the same "Section"/"Key"/and "Value"... but your reading section called "recipies"? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Gyzmok Posted June 8, 2006 Share Posted June 8, 2006 And also why : $input_box= GUICtrlCreateInput("",5,230,75,30) and the $input_box is not used in the script ?? D2charkeeper = No more 'expired characters' in D2.File Date Changer = Change the file date(s), attributes and the filename case of multiple files @ once.Updater_full = Copy/Update your autoitscripts, pictures, .mp3, .avi etc ... subdirs from your PC to your memory stick or to your external harddisk. Now with scheduling and logging.Questmapper Link to comment Share on other sites More sharing options...
Aceguy Posted June 8, 2006 Author Share Posted June 8, 2006 ok, sorry, newbie to this. ok, here goes, everthing is ok but when i try to save the listbox, its wrong. Please help. #include <GuiConstants.au3> GUICreate("MyGUI", 191, 316, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $List_1 = GUICtrlCreateList("", 40, 40, 110, 201, BitOR($WS_BORDER, $WS_VSCROLL)) $input_box = GUICtrlCreateInput("", 5, 230, 75, 30) $save = GUICtrlCreateButton("Save list", 5, 280, 50, 30) $var = IniReadSection("c:\documents and settings\ace\desktop\recipies.ini", "recipies") $add = GUICtrlCreateButton("Add to list", 100, 240, 50, 20) For $i = 1 To $var[0][0] GUICtrlSetData($List_1, $var[$i][1] & "|") Next GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $save $in = GUICtrlRead($List_1) IniWrite("c:\documents and settings\ace\desktop\recipies.ini", "recipies", "key", GUICtrlRead($in)) Case $msg = $add $in = GUICtrlRead($input_box) GUICtrlSetData($List_1, $in & "|") EndSelect WEnd Exit Many thanks. [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 8, 2006 Moderators Share Posted June 8, 2006 Care to elaborate on "what" goes wrong? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Aceguy Posted June 8, 2006 Author Share Posted June 8, 2006 my inifile look like this before test ini [recipies] key=onion key=butter key=milk key=cucumber then when i add another item then save, i get test ini [recipies] key= key=butter key=milk key=cucumber any ideas. [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 8, 2006 Moderators Share Posted June 8, 2006 (edited) You shouldn't have the same "key" name everytime, otherwise the result will never be right... GUICtrlRead() with GUICtrlCreateList() only works if you click on the item in the list box or you will get a blank result... I've made a work around with some comments to fix your current issues, and potential ones... please study them.expandcollapse popup#include <GuiConstants.au3> Dim $MyIni = @DesktopDir & "\recipies.ini", $StoreInfo = '', $IniKeyCount = 0 ; $MyIni using macros solves an issue of others not being able to make it work on their computers If Not FileExists($MyIni) Then FileWriteLine($MyIni, '[recipies]') ; If the file doesn't exist, let's make one $MyGUI = GUICreate("MyGUI", 191, 316, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) ; Get in the habbit of always giving your GUI a variable name to store the handle $List_1 = GUICtrlCreateList("", 40, 40, 110, 201, BitOR($WS_BORDER, $WS_VSCROLL)) $input_box = GUICtrlCreateInput("", 5, 230, 75, 30) $save = GUICtrlCreateButton("Save list", 5, 280, 50, 30) $var = IniReadSection($MyIni, "recipies") $add = GUICtrlCreateButton("Add to list", 100, 240, 50, 20) If IsArray($var) Then ; Lets make sure it's actually formatted or we will throw an error $IniKeyCount = $var[0][0] For $i = 1 To $var[0][0] GUICtrlSetData($List_1, $var[$i][1] & "|") Next EndIf GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $save If $StoreInfo <> '' Then $Array = StringSplit(StringTrimRight($StoreInfo, 1), '|') For $xcount = 1 To UBound($Array) - 1 IniWrite($MyIni, "recipies", $IniKeyCount + $xcount, $Array[$xcount]) ; $IniKeyCount = the key number / $array[$xcount] = the items that were read Next $StoreInfo = '' ; After we've written to the ini let's erase the contents so we don't have duplicates $IniKeyCount = $IniKeyCount + UBound($array) - 1 ; Lets re-add the new amount to the inicount we had before for the keys...that way we don't have to do another inireadsection EndIf Case $msg = $add $in = GUICtrlRead($input_box) GUICtrlSetData($List_1, $in & "|") $StoreInfo = $StoreInfo & $in & '|' ;Since the "List Box" must be clicked to be read with GUICtrlRead() we will store the information everytime you click add EndSelect WEnd Exit Edited June 8, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Aceguy Posted June 8, 2006 Author Share Posted June 8, 2006 Thank you sooooo much. [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock Link to comment Share on other sites More sharing options...
Aceguy Posted June 8, 2006 Author Share Posted June 8, 2006 Yep Works like a treat, however, i have another problem, im totally lost. what you have written doesnt make sense to me. (Maybe i'm too old for this, LOL) thanks again tho. [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 8, 2006 Moderators Share Posted June 8, 2006 Maybe you should try Valuaters Welcome to AutoIt 123... it may give you better grasp on things now and to come.http://www.autoitscript.com/forum/index.php?showtopic=21048 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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