seszi Posted September 25, 2007 Share Posted September 25, 2007 Hi! i use a gui with 300 items, where i made an array for each item to hold the kind of it, like 0=text 1=checkbox 2=input 3=combo, etc so the array looks like 1,2,1,0,3,1,1,1,3,3,2 when i save the guidata to a file, i just dump the guidata into lines of a text file when i load it, i check the appropriate item from the array to see what to do with the written data, cause a "4" can be a text item or even a state sign for a checkbox this works well, but it makes hard to add items to the gui question: can i get the gui kind just by the gui item's serial number? thanks in advance! Link to comment Share on other sites More sharing options...
Bert Posted September 25, 2007 Share Posted September 25, 2007 WIth a GUI, you can use the control's ID to do what you need. Also, you may want to use a ini file to keep stuff strait. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
seszi Posted September 25, 2007 Author Share Posted September 25, 2007 WIth a GUI, you can use the control's ID to do what you need. Also, you may want to use a ini file to keep stuff strait. I think U get me wrong, its becouse my poor english these are my save/load functions: Func Save() $FileName = FileSaveDialog("Save settings...", "", "(*.ini)", 2) $WriteThis = FileOpen($FileName & ".ini", 2) sleep(100) For $a = 5 to $SSB + 9;$SSB is the counter for all GUI controls FileWriteLine($WriteThis, GUICtrlRead($a)) Next If $Filename <> "" Then FileClose($FileName) EndFUnc Func Open() $FileName = FileOpenDialog("Open saved settings...", "", "(*.ini)", 1) $ReadThis = FileOpen($FileName, 0) sleep(100) $a = 5 While 1 $line = FileReadLine($ReadThis) If @error = -1 Then ExitLoop If StringMid($GCR, $a, 1) = "1" AND $line <> "" Then GUICtrlSetData($a, $line);$GCR is my array with gui control types listed If StringMid($GCR, $a, 1) = "2" AND $line == "4" Then GUICtrlSetState ($a, $GUI_UNCHECKED) If StringMid($GCR, $a, 1) = "2" AND $line == "1" Then GUICtrlSetState ($a, $GUI_CHECKED) $a = $a + 1 Wend If $Filename <> "" Then FileClose($FileName) EndFUnc so i need to know a type of each gui control, when i read back the data from the file, to know what to do with a "4" or a "1" they can be simple text data, or state of a checkbox i need something like: if GUICtrlGetType($a) = "CheckBox" Then... (set GUICtrlSetState to checked/unchecked according to the saved data, "4" or "1") ELSE... (set GuiCtrlData to the saved data, since it is an input control) Link to comment Share on other sites More sharing options...
martin Posted September 25, 2007 Share Posted September 25, 2007 I think U get me wrong, its becouse my poor english these are my save/load functions: Func Save() $FileName = FileSaveDialog("Save settings...", "", "(*.ini)", 2) $WriteThis = FileOpen($FileName & ".ini", 2) sleep(100) For $a = 5 to $SSB + 9;$SSB is the counter for all GUI controls FileWriteLine($WriteThis, GUICtrlRead($a)) Next If $Filename <> "" Then FileClose($FileName) EndFUnc Func Open() $FileName = FileOpenDialog("Open saved settings...", "", "(*.ini)", 1) $ReadThis = FileOpen($FileName, 0) sleep(100) $a = 5 While 1 $line = FileReadLine($ReadThis) If @error = -1 Then ExitLoop If StringMid($GCR, $a, 1) = "1" AND $line <> "" Then GUICtrlSetData($a, $line);$GCR is my array with gui control types listed If StringMid($GCR, $a, 1) = "2" AND $line == "4" Then GUICtrlSetState ($a, $GUI_UNCHECKED) If StringMid($GCR, $a, 1) = "2" AND $line == "1" Then GUICtrlSetState ($a, $GUI_CHECKED) $a = $a + 1 Wend If $Filename <> "" Then FileClose($FileName) EndFUnc so i need to know a type of each gui control, when i read back the data from the file, to know what to do with a "4" or a "1" they can be simple text data, or state of a checkbox i need something like: if GUICtrlGetType($a) = "CheckBox" Then... (set GUICtrlSetState to checked/unchecked according to the saved data, "4" or "1") ELSE... (set GuiCtrlData to the saved data, since it is an input control) Looks to me like you have made it difficult for yourself earlier in your script, and my suggestion is that you consider changing it. When you create the controls you must know what sort of control to create, so if you want arrays of controls then I think you should have a different array for each type of control. So you have $ChkArray[] and BtnArray[] etc. Then when you save the data to an ini you can have a loop for each control type, and have a section for buttons, a section for checkboxes etc. There is then no need to work out what type of control each one is and it's easier. [CheckBoxes] CheckBoxcount = 5 ChkCaption = stop, include,single,double,none ChkState = 1,0,0,0,0 ChkTopLeft=10,10,10,10 . . . [buttons] BtnCount = 2 BtnCaption = ..... Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. 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