Pedi7o Posted August 13, 2011 Share Posted August 13, 2011 (edited) I have this ini file which contains 5 different variables. So i want some help to get the data from the ini file and then create a gui, create 1 checkbox for every "Name" key. Then, if a checkbox is checked, write a registry key for every "key" key + "value" key + "path" key + "reg" key. Settings.ini expandcollapse popup[1] Name = a Key = key1 Value1 = 100 Value2 = 200 Value3 = 300 Path1 = patha Path2 = pathb Path3 = pathc Reg1 = rega Reg2 = regb Reg3 = regc [2] Name = b Key = key2 Value1 = 100 Value2 = 200 Value3 = 300 Path1 = patha Path2 = pathb Path3 = pathc Reg1 = rega Reg2 = regb Reg3 = regc [3] Name = c Key = key3 Value1 = 100 Value2 = 200 Value3 = 300 Path1 = patha Path2 = pathb Path3 = pathc Reg1 = rega Reg2 = regb Reg3 = regc Thanks in advance. Edited August 13, 2011 by Pedi7o Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 13, 2011 Moderators Share Posted August 13, 2011 Pedi7o, That seems quite a reasonable task to code with AutoIt. What have you done so far which does not work? 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...
Pedi7o Posted August 13, 2011 Author Share Posted August 13, 2011 (edited) Hello, so far I have this but is not exactly as practical as I want. expandcollapse popup#include <GUIConstantsEx.au3> Opt ("TrayIconDebug", 1) ;#NoTrayIcon Global $Var[1] $KeyMain = "HKEY_LOCAL_MACHINE\SoFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx" $IniFile = @ScriptDir & "\Setting.ini" GUICreate ("Instalando programas") $Check_1 = GUICtrlCreateCheckbox (IniRead ($IniFile, "1", "Name", "Empty"), 10, 10, 120, 20) $Check_2 = GUICtrlCreateCheckbox (IniRead ($IniFile, "2", "Name", "Empty"), 10, 30, 120, 20) $Check_3 = GUICtrlCreateCheckbox (IniRead ($IniFile, "3", "Name", "Empty"), 10, 50, 120, 20) $Save = GUICtrlCreateButton ("Save", 150, 250, 60, 30) $Exit = GUICtrlCreateButton ("Exit", 220, 250, 60, 30) GUISetState() While 1 $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE Exit Case $iMsg = $Check_1 If GUICtrlRead ($Check_1) = $GUI_CHECKED Then MsgBox (0, "", "CHECKED") RegWrite ($KeyMain & "\" & IniRead ($IniFile, "1", "Key1", "Empty"), "", "REG_SZ", IniRead ($IniFile, "1", "Name", "Empty")) RegWrite ($KeyMain & "\" & IniRead ($IniFile, "1", "Key1", "Empty"), "100", "REG_SZ", IniRead ($IniFile, "1", "Path1", "Empty")) RegWrite ($KeyMain & "\" & IniRead ($IniFile, "1", "Key1", "Empty"), "200", "REG_SZ", IniRead ($IniFile, "1", "Path2", "Empty")) RegWrite ($KeyMain & "\" & IniRead ($IniFile, "1", "Key1", "Empty"), "300", "REG_SZ", IniRead ($IniFile, "1", "Path3", "Empty")) RegWrite ($KeyMain & "\" & IniRead ($IniFile, "1", "Key1", "Empty"), "400", "REG_SZ", IniRead ($IniFile, "1", "Path4", "Empty")) EndIf Case $iMsg = $Save MsgBox (64, "", "Save!") Case $iMsg = $Exit Exit EndSelect WEnd Edited August 13, 2011 by Pedi7o Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 13, 2011 Moderators Share Posted August 13, 2011 Pedi7o, Does this look more "practical": expandcollapse popup#include <GUIConstantsEx.au3> $IniFile = @ScriptDir & "\Setting.ini" GUICreate ("Instalando programas") $Check_1 = GUICtrlCreateCheckbox (IniRead ($IniFile, "1", "Name", "Empty"), 10, 10, 120, 20) $Check_2 = GUICtrlCreateCheckbox (IniRead ($IniFile, "2", "Name", "Empty"), 10, 30, 120, 20) $Check_3 = GUICtrlCreateCheckbox (IniRead ($IniFile, "3", "Name", "Empty"), 10, 50, 120, 20) $Save = GUICtrlCreateButton ("Save", 150, 250, 60, 30) $Exit = GUICtrlCreateButton ("Exit", 220, 250, 60, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $Exit Exit Case $Save If GUICtrlRead ($Check_1) = $GUI_CHECKED Then MsgBox (0, "", "1 CHECKED") Write_Reg(1) EndIf If GUICtrlRead ($Check_2) = $GUI_CHECKED Then MsgBox (0, "", "2 CHECKED") Write_Reg(2) EndIf If GUICtrlRead ($Check_3) = $GUI_CHECKED Then MsgBox (0, "", "3 CHECKED") Write_Reg(3) EndIf Case $Save MsgBox (64, "", "Save!") EndSwitch WEnd Func Write_Reg($iIndex) RegWrite ($KeyMain & "\" & IniRead ($IniFile, $iIndex, "Key" & $iIndex, "Empty"), "", "REG_SZ", IniRead ($IniFile, $iIndex, "Name", "Empty")) For $i = 1 To 3 RegWrite ($KeyMain & "\" & IniRead ($IniFile, $iIndex, "Key" & $i, "Empty"), 100 * $i, "REG_SZ", IniRead ($IniFile, $iIndex, "Path" & $i, "Empty")) Next EndFunc Not tested because I do not like filling up my registry with garbage. 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...
Pedi7o Posted August 13, 2011 Author Share Posted August 13, 2011 Lol, sure. Thanks you, Melba23 Btw, That's what virtual machines are for. I'll check and test. I wonder if there a way to get all the key values from the ini, create a checkbox and write its respective registry key. I mean something like this: ; Create CheckBoxes For $i = 1 To $aChecks[0][0] $aChecks[$i][0] = GUICtrlCreateCheckbox($aChecks[$i][1], 10, ($i * 30) + 20, 100, 20) Next Link to comment Share on other sites More sharing options...
Pedi7o Posted August 13, 2011 Author Share Posted August 13, 2011 (edited) Update: Im editing the ini file and the code. And is working so far. Edited August 13, 2011 by Pedi7o Link to comment Share on other sites More sharing options...
Syed23 Posted August 16, 2011 Share Posted August 16, 2011 Melba23, I have just used your code and modified something to my knowledge. Please correct me if i am wrong! expandcollapse popup#include <GUIConstantsEx.au3> $file = IniReadSectionNames(@ScriptDir & "\Settings.ini") GUICreate ("Instalando programas") If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else $count = 10 For $i = 1 To $file[0] GUICtrlCreateCheckbox(IniRead ($file, "1", "Name", "Empty"), 10, $count, 120, 20) $count = $count + 20 Next EndIf $Save = GUICtrlCreateButton ("Save", 150, 250, 60, 30) $Exit = GUICtrlCreateButton ("Exit", 220, 250, 60, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $Exit Exit Case $Save If GUICtrlRead ($Check_1) = $GUI_CHECKED Then MsgBox (0, "", "1 CHECKED") Write_Reg(1) EndIf If GUICtrlRead ($Check_2) = $GUI_CHECKED Then MsgBox (0, "", "2 CHECKED") Write_Reg(2) EndIf If GUICtrlRead ($Check_3) = $GUI_CHECKED Then MsgBox (0, "", "3 CHECKED") Write_Reg(3) EndIf Case $Save MsgBox (64, "", "Save!") EndSwitch WEnd Func Write_Reg($iIndex) RegWrite ($KeyMain & "\" & IniRead ($IniFile, $iIndex, "Key" & $iIndex, "Empty"), "", "REG_SZ", IniRead ($IniFile, $iIndex, "Name", "Empty")) For $i = 1 To 3 RegWrite ($KeyMain & "\" & IniRead ($IniFile, $iIndex, "Key" & $i, "Empty"), 100 * $i, "REG_SZ", IniRead ($IniFile, $iIndex, "Path" & $i, "Empty")) Next EndFunc Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font] 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