facet Posted December 1, 2007 Share Posted December 1, 2007 Hi, I have one question:I have script, which reads states from file INI. I would like this strings ($PROG1 and $GUI_CHECKED) put on into GuiCtrlCreateCheckbox[Zestaw] Zestaw=Inne [Inne] $PROG1=$GUI_CHECKED [Hanipol] $PROG2=$GUI_CHECKED [Uś] $PROG3=$GUI_CHECKED [Ateko] $PROG4=$GUI_CHECKED $PROG8=$GUI_CHECKEDFile INICODE#include <GuiConstants.au3>GuiCreate(" INSTALUJ V1.0", 300, 400)GuiSetIcon("install.exe", 0)$W_PIONIE=0GUIStartGroup()$W_PIONIE=5+$W_PIONIE$INNE=GuiCtrlCreateRadio("Inne", 5, $W_PIONIE,40)$HANIPOL=GuiCtrlCreateRadio("Hanipol", 50, $W_PIONIE,60)$US=GuiCtrlCreateRadio("Uś", 110, $W_PIONIE,40)$ATEKO=GuiCtrlCreateRadio("Ateko", 150, $W_PIONIE,50)$W_PIONIE=30+$W_PIONIEGUICtrlCreateLabel("PROGRAM",23,$W_PIONIE) GUICtrlCreateLabel("L",203,$W_PIONIE)GUICtrlCreateLabel("P",253,$W_PIONIE)$W_PIONIE=20+$W_PIONIE$PROG1=GuiCtrlCreateCheckbox("Radmin", 5, $W_PIONIE)$W_PIONIE=20+$W_PIONIE$PROG2=GuiCtrlCreateCheckbox("Allplayer 3.0", 5, $W_PIONIE)$W_PIONIE=20+$W_PIONIE$PROG3=GuiCtrlCreateCheckbox("Everest 3,5", 5, $W_PIONIE)$W_PIONIE=20+$W_PIONIE$PROG4=GuiCtrlCreateCheckbox("JavaVM", 5, $W_PIONIE)$W_PIONIE=20+$W_PIONIE$PROG5=GuiCtrlCreateCheckbox("Putty", 5, $W_PIONIE)$W_PIONIE=20+$W_PIONIE$PROG6=GuiCtrlCreateCheckbox("Total Commander 7.01", 5, $W_PIONIE)$W_PIONIE=20+$W_PIONIE$PROG7=GuiCtrlCreateCheckbox("GaduReader", 5, $W_PIONIE)$W_PIONIE=20+$W_PIONIE$PROG8=GuiCtrlCreateCheckbox("Ghost", 5, $W_PIONIE);USTAWIENIA$INI = IniRead("install.ini", "Zestaw", "Zestaw", "Inne")If $INI=="Inne" Then GuiCtrlSetState($INNE, $GUI_CHECKED)ElseIf $INI=="Hanipol" Then GuiCtrlSetState($HANIPOL, $GUI_CHECKED)ElseIf $INI=="Uś" Then GuiCtrlSetState($US, $GUI_CHECKED)ElseIf $INI=="Ateko" Then GuiCtrlSetState($ATEKO, $GUI_CHECKED)EndIfIf $INI == "Inne" then $INI = IniReadSection("install.ini", "Inne") For $i = 1 To $INI[0][0] MsgBox(0,"",$INI[$i][0] & " i " & $INI[$i][1]) ; is OK GuiCtrlSetState($INI[$i][0], $INI[$i][1]) ; is not OK NextElseIf $INI == "Hanipol" then $INI = IniReadSection("install.ini", "Hanipol") For $i = 1 To $INI[0][0] GuiCtrlSetState($INI[$i][0], $INI[$i][1]) NextElseIf $INI == "Uś" then $INI = IniReadSection("install.ini", "Uś") For $i = 1 To $INI[0][0] GuiCtrlSetState($INI[$i][0], $INI[$i][1]) ;GuiCtrlSetState($PROG3, $GUI_CHECKED) NextElseIf $INI == "Ateko" then $INI = IniReadSection("install.ini", "Ateko") For $i = 1 To $INI[0][0] GuiCtrlSetState($INI[$i][0], $INI[$i][1]) NextEndIf;GUIStartGroup();$W_PIONIE=20+$W_PIONIE;$PROG8=GuiCtrlCreateCheckbox("Ghost", 5, $W_PIONIE);GuiCtrlSetState(-1, $GUI_CHECKED);$L2=GuiCtrlCreateRadio("", 200, 40) ;GuiCtrlSetState(-1, $GUI_CHECKED);$P2=GuiCtrlCreateRadio("", 250, 40);GuiCtrlSetState(-1, $GUI_UNCHECKED)$ZAISTALUJ = GUICtrlCreateButton ("&ZAISTALUJ",110,370,80,20)GUICtrlSetState(-1, $GUI_FOCUS + $GUI_DEFBUTTON)GUISetState () ; will display an dialog box with 2 buttonWhile 1 ;zapis ustawien ;$CFG = "PROG1=test" ;IniWriteSection("install.ini", "Zestaw", $CFG) ;IniWriteSection("install.ini", "Inne", $CFG) ;IniWriteSection("install.ini", "Hanipol", $CFG) ;IniWriteSection("install.ini", "Uś", $CFG) ;IniWriteSection("install.ini", "Ateko", $CFG) $msg = GUIGetMsg() If $msg = $INNE And GUICtrlRead($INNE) = $GUI_CHECKED then $INI = IniReadSection("install.ini", "Inne") For $i = 1 To $INI[0][0] MsgBox(4096, "", "Key: " & $INI[$i][0] & @CRLF & "Value: " & $INI[$i][1] & @CRLF & $INI[0][0]) Next ElseIf $msg = $HANIPOL And GUICtrlRead($HANIPOL) = $GUI_CHECKED then $INI = IniReadSection("install.ini", "Hanipol") For $i = 1 To $INI[0][0] MsgBox(4096, "", "Key: " & $INI[$i][0] & @CRLF & "Value: " & $INI[$i][1] & @CRLF & $INI[0][0]) Next ElseIf $msg = $US And GUICtrlRead($US) = $GUI_CHECKED then $INI = IniReadSection("install.ini", "Uś") For $i = 1 To $INI[0][0] MsgBox(4096, "", "Key: " & $INI[$i][0] & @CRLF & "Value: " & $INI[$i][1] & @CRLF & $INI[0][0]) Next ElseIf $msg = $ATEKO And GUICtrlRead($ATEKO) = $GUI_CHECKED then $INI = IniReadSection("install.ini", "Ateko") For $i = 1 To $INI[0][0] MsgBox(4096, "", "Key: " & $INI[$i][0] & @CRLF & "Value: " & $INI[$i][1] & @CRLF & $INI[0][0]) Next EndIf If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $ZAISTALUJ Then If GUICtrlRead($PROG1) = $GUI_CHECKED Then RunWait("skrypt\radmin.exe",@ScriptDir&"/skrypt") If GUICtrlRead($PROG2) = $GUI_CHECKED Then RunWait("skrypt\allplayer.exe",@ScriptDir&"/skrypt") If GUICtrlRead($PROG3) = $GUI_CHECKED Then RunWait("skrypt\everest.exe",@ScriptDir&"/skrypt") If GUICtrlRead($PROG4) = $GUI_CHECKED Then RunWait("skrypt\javavm.exe",@ScriptDir&"/skrypt") If GUICtrlRead($PROG5) = $GUI_CHECKED Then RunWait("skrypt\putty.exe",@ScriptDir&"/skrypt") If GUICtrlRead($PROG6) = $GUI_CHECKED Then RunWait("skrypt\totalcmd.exe",@ScriptDir&"/skrypt") If GUICtrlRead($PROG7) = $GUI_CHECKED Then DirCopy("soft\gadureader", @ProgramFilesDir, 1) If GUICtrlRead($PROG8) = $GUI_CHECKED Then DirCopy("soft\ghost", @ProgramFilesDir, 1) EndIf ;If $msg = $ZAISTALUJ And GUICtrlRead($PROG2) = $GUI_CHECKED Then ; If GUICtrlRead($L2) = $GUI_CHECKED Then ; MsgBox(0,"DANE","zaznaczone 2 oraz L") ; Else ; MsgBox(0,"DANE","zaznaczone 2 oraz P") ; EndIf ;EndIfWendMy English is not ok! I'm sorry. Please help me. Thanks! I am write from Poland Link to comment Share on other sites More sharing options...
Bowmore Posted December 1, 2007 Share Posted December 1, 2007 Hi, I have one question: I have script, which reads states from file INI. I would like this strings ($PROG1 and $GUI_CHECKED) put on into GuiCtrlCreateCheckbox [Zestaw] Zestaw=Inne [Inne] $PROG1=$GUI_CHECKED [Hanipol] $PROG2=$GUI_CHECKED [Uś] $PROG3=$GUI_CHECKED [Ateko] $PROG4=$GUI_CHECKED $PROG8=$GUI_CHECKEDFile INI ... My English is not ok! I'm sorry. Please help me. Thanks! I am write from Poland Use some code like this to save the state of your checkboxes to the ini file If $INI == "Inne" then For $i = 1 To $INI[0][0] IniWrite("install.ini", "Inne", GUICtrlRead($INI[$i][0])) Next EndIf Your code for reading the ini file is OK. The problem is with the values in your ini file. You have the stored the name of the contstant $GUI_CHECKED of $GUI_UNCHECKED. what needs to be in the in ini file is the values represented by these ccntants. $GUI_CHECKED = 1 $GUI_UNCHECKED = 4 These are the values that the above code will save so your ini would look like this [Zestaw] Zestaw=Inne [Inne] $PROG1=1 [Hanipol] $PROG2=1 [Us] $PROG3=1 [Ateko] $PROG4=1 $PROG8=1 I think this is OK If $INI == "Inne" then $INI = IniReadSection("install.ini", "Inne") For $i = 1 To $INI[0][0] MsgBox(0,"",$INI[$i][0] & " i " & $INI[$i][1]) ; is OK GuiCtrlSetState($INI[$i][0], $INI[$i][1]) ; is not OK Next EndIf "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
facet Posted December 1, 2007 Author Share Posted December 1, 2007 It does not it act unfortunately. After change in GuiCtrlSetState($INI[$i][0], $INI[$i][1]) from $INI[$i][0] on $ PROG1 (GuiCtrlSetState($PROG1, $INI[$i][1])) acts and marks, Please HELP I altered file ini. I greet Link to comment Share on other sites More sharing options...
facet Posted December 1, 2007 Author Share Posted December 1, 2007 PLEASE HELP ME Link to comment Share on other sites More sharing options...
Bowmore Posted December 2, 2007 Share Posted December 2, 2007 PLEASE HELP ME I think this should work as expected for you and enable you to complete your script. Ini file note: changed [us'] to [us] [Zestaw] Zestaw=Inne [Inne] $PROG1=1 [Hanipol] $PROG2=1 [Us] $PROG3=1 [Ateko] $PROG4=1 $PROG8=1 The main change is that I have put all the check box handles in an array so that you can us a simple loop to check and uncheck them. I have also used the Tidy tool in SciTE to make the code easier to read. expandcollapse popup#include <GuiConstants.au3> GUICreate(" INSTALUJ V1.0", 300, 400) GUISetIcon("install.exe", 0) Global $PROG[9] ; Array for the handles of the check boxes $PROG[0] = 8 ;The number of check boxes Global $ProgNo = 0 $W_PIONIE = 0 GUIStartGroup() $W_PIONIE += 5 $INNE = GUICtrlCreateRadio("Inne", 5, $W_PIONIE, 40) $HANIPOL = GUICtrlCreateRadio("Hanipol", 50, $W_PIONIE, 60) $US = GUICtrlCreateRadio("Us", 110, $W_PIONIE, 40) $ATEKO = GUICtrlCreateRadio("Ateko", 150, $W_PIONIE, 50) $W_PIONIE += 30 GUICtrlCreateLabel("PROGRAM", 23, $W_PIONIE) GUICtrlCreateLabel("L", 203, $W_PIONIE) GUICtrlCreateLabel("P", 253, $W_PIONIE) $W_PIONIE += 20 $PROG[1] = GUICtrlCreateCheckbox("Radmin", 5, $W_PIONIE) $W_PIONIE += 20 $PROG[2] = GUICtrlCreateCheckbox("Allplayer 3.0", 5, $W_PIONIE) $W_PIONIE += 20 $PROG[3] = GUICtrlCreateCheckbox("Everest 3,5", 5, $W_PIONIE) $W_PIONIE += 20 $PROG[4] = GUICtrlCreateCheckbox("JavaVM", 5, $W_PIONIE) $W_PIONIE += 20 $PROG[5] = GUICtrlCreateCheckbox("Putty", 5, $W_PIONIE) $W_PIONIE += 20 $PROG[6] = GUICtrlCreateCheckbox("Total Commander 7.01", 5, $W_PIONIE) $W_PIONIE += 20 $PROG[7] = GUICtrlCreateCheckbox("GaduReader", 5, $W_PIONIE) $W_PIONIE += 20 $PROG[8] = GUICtrlCreateCheckbox("Ghost", 5, $W_PIONIE) ;USTAWIENIA $INI = IniRead("install.ini", "Zestaw", "Zestaw", "Inne") If $INI == "Inne" Then GUICtrlSetState($INNE, $GUI_CHECKED) ElseIf $INI == "Hanipol" Then GUICtrlSetState($HANIPOL, $GUI_CHECKED) ElseIf $INI == "Us" Then GUICtrlSetState($US, $GUI_CHECKED) ElseIf $INI == "Ateko" Then GUICtrlSetState($ATEKO, $GUI_CHECKED) EndIf If $INI == "Inne" Then $INI = IniReadSection("install.ini", "Inne") ;Uncheck all the check boxes For $i = 1 To $PROG[0] GUICtrlSetState($PROG[$i], $GUI_UNCHECKED) Next ; Check the boxes read from install.ini For $i = 1 To $INI[0][0] $ProgNo = StringMid($INI[$i][0],6) GUICtrlSetState($PROG[$ProgNo], $GUI_CHECKED) Next ElseIf $INI == "Hanipol" Then $INI = IniReadSection("install.ini", "Hanipol") ;Uncheck all the check boxes For $i = 1 To $PROG[0] GUICtrlSetState($PROG[$i], $GUI_UNCHECKED) Next ; Check the boxes read from install.ini For $i = 1 To $INI[0][0] $ProgNo = StringMid($INI[$i][0],6) GUICtrlSetState($PROG[$ProgNo], $GUI_CHECKED) Next ElseIf $INI == "Us" Then $INI = IniReadSection("install.ini", "Us") ;Uncheck all the check boxes For $i = 1 To $PROG[0] GUICtrlSetState($PROG[$i], $GUI_UNCHECKED) Next ; Check the boxes read from install.ini For $i = 1 To $INI[0][0] $ProgNo = StringMid($INI[$i][0],6) GUICtrlSetState($PROG[$ProgNo], $GUI_CHECKED) Next ElseIf $INI == "Ateko" Then $INI = IniReadSection("install.ini", "Ateko") ;Uncheck all the check boxes For $i = 1 To $PROG[0] GUICtrlSetState($PROG[$i], $GUI_UNCHECKED) Next ; Check the boxes read from install.ini For $i = 1 To $INI[0][0] $ProgNo = StringMid($INI[$i][0],6) GUICtrlSetState($PROG[$ProgNo], $GUI_CHECKED) Next EndIf ;GUIStartGroup() ;$W_PIONIE=20+$W_PIONIE ;$PROG8=GuiCtrlCreateCheckbox("Ghost", 5, $W_PIONIE) ;GuiCtrlSetState(-1, $GUI_CHECKED) ;$L2=GuiCtrlCreateRadio("", 200, 40) ;GuiCtrlSetState(-1, $GUI_CHECKED) ;$P2=GuiCtrlCreateRadio("", 250, 40) ;GuiCtrlSetState(-1, $GUI_UNCHECKED) $ZAISTALUJ = GUICtrlCreateButton("&ZAISTALUJ", 110, 370, 80, 20) GUICtrlSetState(-1, $GUI_FOCUS + $GUI_DEFBUTTON) GUISetState() ; will display an dialog box with 2 button While 1 ;zapis ustawien ;$CFG = "PROG1=test" ;IniWriteSection("install.ini", "Zestaw", $CFG) ;IniWriteSection("install.ini", "Inne", $CFG) ;IniWriteSection("install.ini", "Hanipol", $CFG) ;IniWriteSection("install.ini", "Us", $CFG) ;IniWriteSection("install.ini", "Ateko", $CFG) $msg = GUIGetMsg() If $msg = $INNE And GUICtrlRead($INNE) = $GUI_CHECKED Then $INI = IniReadSection("install.ini", "Inne") ;Uncheck all the check boxes For $i = 1 To $PROG[0] GUICtrlSetState($PROG[$i], $GUI_UNCHECKED) Next ; Check the boxes read fron install.ini For $i = 1 To $INI[0][0] $ProgNo = StringMid($INI[$i][0],6) GUICtrlSetState($PROG[$ProgNo], $GUI_CHECKED) Next ElseIf $msg = $HANIPOL And GUICtrlRead($HANIPOL) = $GUI_CHECKED Then $INI = IniReadSection("install.ini", "Hanipol") ;Uncheck all the check boxes For $i = 1 To $PROG[0] GUICtrlSetState($PROG[$i], $GUI_UNCHECKED) Next ; Check the boxes read from install.ini For $i = 1 To $INI[0][0] $ProgNo = StringMid($INI[$i][0],6) GUICtrlSetState($PROG[$ProgNo], $GUI_CHECKED) Next ElseIf $msg = $US And GUICtrlRead($US) = $GUI_CHECKED Then $INI = IniReadSection("install.ini", "Us") ;Uncheck all the check boxes For $i = 1 To $PROG[0] GUICtrlSetState($PROG[$i], $GUI_UNCHECKED) Next ; Check the boxes read from install.ini For $i = 1 To $INI[0][0] $ProgNo = StringMid($INI[$i][0],6) GUICtrlSetState($PROG[$ProgNo], $GUI_CHECKED) Next ElseIf $msg = $ATEKO And GUICtrlRead($ATEKO) = $GUI_CHECKED Then $INI = IniReadSection("install.ini", "Ateko") ;Uncheck all the check boxes For $i = 1 To $PROG[0] GUICtrlSetState($PROG[$i], $GUI_UNCHECKED) Next ; Check the boxes read from install.ini For $i = 1 To $INI[0][0] $ProgNo = StringMid($INI[$i][0],6) GUICtrlSetState($PROG[$ProgNo], $GUI_CHECKED) Next EndIf If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $ZAISTALUJ Then ;Save boxes to ini if required SaveSettings() If GUICtrlRead($PROG[1]) = $GUI_CHECKED Then RunWait("skrypt\radmin.exe", @ScriptDir & "/skrypt") If GUICtrlRead($PROG[2]) = $GUI_CHECKED Then RunWait("skrypt\allplayer.exe", @ScriptDir & "/skrypt") If GUICtrlRead($PROG[3]) = $GUI_CHECKED Then RunWait("skrypt\everest.exe", @ScriptDir & "/skrypt") If GUICtrlRead($PROG[4]) = $GUI_CHECKED Then RunWait("skrypt\javavm.exe", @ScriptDir & "/skrypt") If GUICtrlRead($PROG[5]) = $GUI_CHECKED Then RunWait("skrypt\putty.exe", @ScriptDir & "/skrypt") If GUICtrlRead($PROG[6]) = $GUI_CHECKED Then RunWait("skrypt\totalcmd.exe", @ScriptDir & "/skrypt") If GUICtrlRead($PROG[7]) = $GUI_CHECKED Then DirCopy("soft\gadureader", @ProgramFilesDir, 1) If GUICtrlRead($PROG[8]) = $GUI_CHECKED Then DirCopy("soft\ghost", @ProgramFilesDir, 1) EndIf ;If $msg = $ZAISTALUJ And GUICtrlRead($PROG2) = $GUI_CHECKED Then ; If GUICtrlRead($L2) = $GUI_CHECKED Then ; MsgBox(0,"DANE","zaznaczone 2 oraz L") ; Else ; MsgBox(0,"DANE","zaznaczone 2 oraz P") ; EndIf ;EndIf WEnd Func SaveSettings() Local $Section = '' Local $Key = '' If GUICtrlRead($INNE) = $GUI_CHECKED Then $Section = "Inne" ElseIf GUICtrlRead($HANIPOL) = $GUI_CHECKED Then $Section = "Hanipol" ElseIf GUICtrlRead($US) = $GUI_CHECKED Then $Section = "Us" ElseIf GUICtrlRead($ATEKO) = $GUI_CHECKED Then $Section = "Ateko" EndIf For $i = 1 To $PROG[0] $Key = "$PROG" & $i If GUICtrlRead($PROG[$i]) = $GUI_CHECKED Then IniWrite ( "install.ini", $Section, $Key, $GUI_CHECKED) Else IniWrite ( "install.ini", $Section, $Key, $GUI_UNCHECKED) EndIf Next EndFunc "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
facet Posted December 2, 2007 Author Share Posted December 2, 2007 Very very THANKS !!! 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