Rogue5099 Posted March 31, 2009 Share Posted March 31, 2009 I want a GUI that will allow people to check them then it save what they check to add together parameters. I tried just useing a String but I don't think I grasped the adding to string concept. So I did a bunch of If statements. Below is what I have if anyone can make it better or even work that would be great. I keep getting the Else "Error". I put that in to test but thats all I get. expandcollapse popup#include <GuiCopar3tants.au3> Opt("GUIOnEventMode", 1) Global $CommandLine = "" GUICreate("Parameters", 300, 130, -1, @DesktopHeight/10) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUICtrlSetFont(-1, 16, 600) $par1 = GUICtrlCreateCheckbox("-par1", 10, 10, 250, 25) $par2 = GUICtrlCreateCheckbox("-par2", 10, 30, 250, 25) $par3 = GUICtrlCreateCheckbox("-par3", 10, 50, 250, 25) $par4 = GUICtrlCreateCheckbox("-par4", 10, 70, 290, 25) $ok = GUICtrlCreateButton("Ok", 115, 100, 80, 25) GUICtrlSetOnEvent(-1, "OK") GUISetState (@SW_SHOW) While 1 Sleep(1000) WEnd Func OK() GUICtrlGetState($par1) GUICtrlGetState($par2) GUICtrlGetState($par3) GUICtrlGetState($par4) If ($par1 = $GUI_CHECKED) And ($par2 = $GUI_UNCHECKED And $par3 = $GUI_UNCHECKED And $par4 = $GUI_UNCHECKED) Then $CommandLine = "-par1" ElseIf ($par1 And $par2 = $GUI_CHECKED) And ($par3 And $par4 = $GUI_UNCHECKED) Then $CommandLine = "-par1 -par2" ElseIf ($par1 And $par2 And $par3 = $GUI_CHECKED) and ($par4 = $GUI_UNCHECKED) Then $CommandLine = "-par1 -par2 -par3" ElseIf ($par1 And $par2 And $par4 = $GUI_CHECKED) and ($par3 = $GUI_UNCHECKED) Then $CommandLine = "-par1 -par2 -par4" ElseIf ($par1 And $par4 = $GUI_CHECKED) and ($par2 And $par3 = $GUI_UNCHECKED) Then $CommandLine = "-par1 -par4" ElseIf ($par1 And $par3 = $GUI_CHECKED) and ($par2 And $par4 = $GUI_UNCHECKED) Then $CommandLine = "-par1 -par3" ElseIf ($par1 And $par3 And $par4 = $GUI_CHECKED) and ($par2 = $GUI_UNCHECKED) Then $CommandLine = "-par1 -par3 -par4" ElseIf ($par2 = $GUI_CHECKED) And ($par1 And $par3 And $par4 = $GUI_UNCHECKED) Then $CommandLine = "-par2" ElseIf ($par2 And $par3 = $GUI_CHECKED) and ($par1 And $par4 = $GUI_UNCHECKED) Then $CommandLine = "-par2 -par3" ElseIf ($par2 And $par3 And $par4 = $GUI_CHECKED) And ($par1 = $GUI_UNCHECKED) Then $CommandLine = "-par2 -par3 -par4" ElseIf ($par2 And $par4 = $GUI_CHECKED) And ($par1 And $par3 = $GUI_UNCHECKED) Then $CommandLine = "-par2 -par4" ElseIf ($par3 = $GUI_CHECKED) And ($par1 And $par2 And $par4 = $GUI_UNCHECKED) Then $CommandLine = "-par3" ElseIf ($par3 And $par4 = $GUI_CHECKED) and ($par1 And $par2 = $GUI_UNCHECKED) Then $CommandLine = "-par3 -par4" ElseIf ($par4 = $GUI_CHECKED) And ($par1 And $par2 And $par3 = $GUI_UNCHECKED) Then $CommandLine = "-par4" ElseIf ($par1 And $par2 And $par3 And $par4 = $GUI_CHECKED) Then $CommandLine = "-par1 -par2 -par3 -par4" ElseIf ($par4 And $par1 And $par2 And $par3 = $GUI_UNCHECKED) Then $CommandLine = "" Else $CommandLine = "Error" EndIf MsgBox($GUI_CHECKED, "Command", $CommandLine) EndFunc Func _Exit() Exit EndFunc My projects: Inventory / Mp3 Inventory, Computer Stats Link to comment Share on other sites More sharing options...
Authenticity Posted March 31, 2009 Share Posted March 31, 2009 Something like this? expandcollapse popup#include <GuiConstantsEx.au3> Opt("GUIOnEventMode", 1) GUICreate("Parameters", 300, 130, -1, @DesktopHeight/10) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUICtrlSetFont(-1, 16, 600) $sCheckState = _SetCheck() $par1 = GUICtrlCreateCheckbox("-par1", 10, 10, 250, 25) GUICtrlSetState(-1, StringMid($sCheckState, 1, 1)) $par2 = GUICtrlCreateCheckbox("-par2", 10, 30, 250, 25) GUICtrlSetState(-1, StringMid($sCheckState, 2, 1)) $par3 = GUICtrlCreateCheckbox("-par3", 10, 50, 250, 25) GUICtrlSetState(-1, StringMid($sCheckState, 3, 1)) $par4 = GUICtrlCreateCheckbox("-par4", 10, 70, 290, 25) GUICtrlSetState(-1, StringMid($sCheckState, 4, 1)) _SetCheck() $ok = GUICtrlCreateButton("Ok", 115, 100, 80, 25) GUICtrlSetOnEvent(-1, "OK") GUISetState () While 1 Sleep(40) WEnd Func OK() Local $sKey = 'HKLM\software\AABBCC' Local $sRawCheck = '' For $i = 1 To 4 If BitAND(GUICtrlRead(Eval('par' & $i)), $GUI_CHECKED) = $GUI_CHECKED Then $sRawCheck &= '1' Else $sRawCheck &= '4' EndIf Next RegWrite($sKey, 'RawCheck', 'REG_SZ', $sRawCheck) EndFunc Func _Exit() Exit EndFunc Func _SetCheck() Local $sKey = 'HKLM\software\AABBCC' Local $sRawCheck = RegRead($sKey, 'RawCheck') If $sRawCheck = '' Then RegWrite($sKey, 'RawCheck', 'REG_SZ', '4444') Return '4444' EndIf Return $sRawCheck EndFunc Link to comment Share on other sites More sharing options...
Valuater Posted March 31, 2009 Share Posted March 31, 2009 ; Actually, It is more preferable to use this Global Array than use eval() Global $par[5] $par[1] = GUICtrlCreateCheckbox("-par1", 10, 10, 250, 25) $par[2] = GUICtrlCreateCheckbox("-par2", 10, 30, 250, 25) $par[3] = GUICtrlCreateCheckbox("-par3", 10, 50, 250, 25) $par[4] = GUICtrlCreateCheckbox("-par4", 10, 70, 290, 25) 8) Link to comment Share on other sites More sharing options...
Rogue5099 Posted March 31, 2009 Author Share Posted March 31, 2009 (edited) I like how it saves the information so i will keep this format but I want to add the checkboxes once saved to insert/remove there parameter into a string. i.e. 1 and second checkbox checked = "-par1 -par2" i.e. 1 and 4th checkbox checked = "-par1 -par4" Edited March 31, 2009 by rogue5099 My projects: Inventory / Mp3 Inventory, Computer Stats Link to comment Share on other sites More sharing options...
ResNullius Posted March 31, 2009 Share Posted March 31, 2009 (edited) This simplifies things assuming all your checkboxes are created sequentially, and their text is equal to the actual parameters they represent #include <GuiConstantsEx.au3> Opt("GUIOnEventMode", 1) Global $CommandLine = "" GUICreate("Parameters", 300, 130, -1, @DesktopHeight / 10) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUICtrlSetFont(-1, 16, 600) $par1 = GUICtrlCreateCheckbox("-par1", 10, 10, 250, 25) $par2 = GUICtrlCreateCheckbox("-par2", 10, 30, 250, 25) $par3 = GUICtrlCreateCheckbox("-par3", 10, 50, 250, 25) $par4 = GUICtrlCreateCheckbox("-par4", 10, 70, 290, 25) $ok = GUICtrlCreateButton("Ok", 115, 100, 80, 25) GUICtrlSetOnEvent(-1, "OK") GUISetState(@SW_SHOW) While 1 Sleep(1000) WEnd Func OK() $CommandLine = "" For $i = $par1 To $par4 If GUICtrlRead($i) = $GUI_CHECKED Then $CommandLine &= GUICtrlRead($i, 1) & " " Next MsgBox(4096+64, "Command", $CommandLine) EndFunc ;==>OK Func _Exit() Exit EndFunc ;==>_Exit Edited March 31, 2009 by ResNullius Link to comment Share on other sites More sharing options...
Valuater Posted April 1, 2009 Share Posted April 1, 2009 Not bad Res... Short and Sweet!! 8) Link to comment Share on other sites More sharing options...
Rogue5099 Posted April 2, 2009 Author Share Posted April 2, 2009 This simplifies things assuming all your checkboxes are created sequentially, and their text is equal to the actual parameters they represent #include <GuiConstantsEx.au3> Opt("GUIOnEventMode", 1) Global $CommandLine = "" GUICreate("Parameters", 300, 130, -1, @DesktopHeight / 10) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUICtrlSetFont(-1, 16, 600) $par1 = GUICtrlCreateCheckbox("-par1", 10, 10, 250, 25) $par2 = GUICtrlCreateCheckbox("-par2", 10, 30, 250, 25) $par3 = GUICtrlCreateCheckbox("-par3", 10, 50, 250, 25) $par4 = GUICtrlCreateCheckbox("-par4", 10, 70, 290, 25) $ok = GUICtrlCreateButton("Ok", 115, 100, 80, 25) GUICtrlSetOnEvent(-1, "OK") GUISetState(@SW_SHOW) While 1 Sleep(1000) WEnd Func OK() $CommandLine = "" For $i = $par1 To $par4 If GUICtrlRead($i) = $GUI_CHECKED Then $CommandLine &= GUICtrlRead($i, 1) & " " Next MsgBox(4096+64, "Command", $CommandLine) EndFunc;==>OK Func _Exit() Exit EndFunc;==>_Exit That is excellant!!! Exactly what I was trying to accomplish and much much more short! Thank you! My projects: Inventory / Mp3 Inventory, Computer Stats 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