AndreasNWWWWW Posted June 7, 2018 Posted June 7, 2018 I got a question: i am trying to run different functions based upon what i select in these radio buttons.(code below) it needs to check server 1. then run function 1 or function 2 after what i selected in the checkbox. once that function is done it moves to the next one, until it has been trough all 5 iv'e tried using while loops with different while $i equals to something but then i manualy need to go in and edit the script every time. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 437, 192, 124) $Server2 = GUICtrlCreateLabel("Server2", 216, 95, 41, 17) $server1 = GUICtrlCreateLabel("Server1", 216, 72, 41, 17) $server4 = GUICtrlCreateLabel("Server4", 216, 144, 41, 17) $server3 = GUICtrlCreateLabel("Server3", 216, 119, 41, 17) $server5 = GUICtrlCreateLabel("Server5", 216, 170, 41, 17) $Start = GUICtrlCreateButton("Start", 240, 248, 147, 25) $Checkbox1 = GUICtrlCreateCheckbox("function1", 288, 72, 97, 17) $Checkbox2 = GUICtrlCreateCheckbox("function2", 392, 72, 97, 17) $Checkbox3 = GUICtrlCreateCheckbox("function1", 288, 96, 97, 17) $Checkbox4 = GUICtrlCreateCheckbox("function2", 392, 96, 97, 17) $Checkbox5 = GUICtrlCreateCheckbox("function1", 288, 120, 97, 17) $Checkbox6 = GUICtrlCreateCheckbox("function2", 392, 120, 97, 17) $Checkbox7 = GUICtrlCreateCheckbox("function1", 288, 144, 97, 17) $Checkbox8 = GUICtrlCreateCheckbox("function2", 392, 144, 97, 17) $Checkbox9 = GUICtrlCreateCheckbox("function1", 288, 170, 97, 17) $Checkbox10 = GUICtrlCreateCheckbox("function2", 392, 170, 97, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd
FrancescoDiMuro Posted June 7, 2018 Posted June 7, 2018 Hi @AndreasNWWWWW So, you have five servers, and you need to run a function ( always the same, differently parameterized I guess? ), basing on which checkbox has been checked ( the first or the second one ). I think you can easily do this with a combination of GUICtrlRead() or GUICtrlGetState() to obtain the value of the checkboxes, and then, call the appropriate function Best Regards. Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
TheXman Posted June 7, 2018 Posted June 7, 2018 18 minutes ago, AndreasNWWWWW said: I got a question: i am trying to run different functions based upon what i select in these radio buttons.(code below) it needs to check server 1. then run function 1 or function 2 after what i selected in the checkbox. once that function is done it moves to the next one, until it has been trough all 5 That's funny. I don't see any questions. I have a question also. Have you spent any time reading the help file to try to figure it out on your own? From the effort you've shown, It doesn't look like it. Try asking to some "real" questions and maybe you'll start getting some real answers. CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
Subz Posted June 7, 2018 Posted June 7, 2018 I'm bored, so wrote the following example: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $aServer[6][8] ;~ Global Array $aServer[0][0] = 5 ;~ Server Array Count ;~ Server 1 Array Info $aServer[1][0] = Null ;~ Reserved for Server 1 » Label Control Handle $aServer[1][1] = "ServerName1" ;~ Server 1 » Label Text Value $aServer[1][2] = Null ;~ Reserved for Server 1 » Function 1 » Control Handle $aServer[1][3] = "Function 1" ;~ Function 1 » Text Value $aServer[1][4] = $GUI_UNCHECKED ;~ Server 1 » Function 1 » Check Value $aServer[1][5] = Null ;~ Reserved for Server 1 » Function 2 » Control Handle $aServer[1][6] = "Function 2" ;~ Function 2 » Text Value $aServer[1][7] = $GUI_UNCHECKED ;~ Server 1 » Function 2 » Check Value ;~ Server 2 Array Info $aServer[2][0] = Null ;~ Reserved for Server 2 » Label Control Handle $aServer[2][1] = "ServerName2" ;~ Server 2 » Label Text Value $aServer[2][2] = Null ;~ Reserved for Server 2 » Function 1 » Control Handle $aServer[2][3] = "Function 1" ;~ Function 1 » Text Value $aServer[2][4] = $GUI_UNCHECKED ;~ Server 2 » Function 1 » Check Value $aServer[2][5] = Null ;~ Reserved for Server 2 » Function 2 » Control Handle $aServer[2][6] = "Function 2" ;~ Function 2 » Text Value $aServer[2][7] = $GUI_UNCHECKED ;~ Server 2 » Function 2 » Check Value ;~ Server 3 Array Info $aServer[3][0] = Null ;~ Reserved for Server 3 » Label Control Handle $aServer[3][1] = "ServerName3" ;~ Server 3 » Label Text Value $aServer[3][2] = Null ;~ Reserved for Server 3 » Function 1 » Control Handle $aServer[3][3] = "Function 1" ;~ Function 1 » Text Value $aServer[3][4] = $GUI_UNCHECKED ;~ Server 3 » Function 1 » Check Value - Not $aServer[3][5] = Null ;~ Reserved for Server 3 » Function 2 » Control Handle $aServer[3][6] = "Function 2" ;~ Function 2 » Text Value $aServer[3][7] = $GUI_UNCHECKED ;~ Server 3 » Function 2 » Check Value ;~ Server 4 Array Info $aServer[4][0] = Null ;~ Reserved for Server 4 » Label Control Handle $aServer[4][1] = "ServerName4" ;~ Server 4 » Label Text Value $aServer[4][2] = Null ;~ Reserved for Server 4 » Function 1 » Control Handle $aServer[4][3] = "Function 1" ;~ Function 1 » Text Value $aServer[4][4] = $GUI_UNCHECKED ;~ Server 4 » Function 1 » Check Value $aServer[4][5] = Null ;~ Reserved for Server 4 » Function 2 » Control Handle $aServer[4][6] = "Function 2" ;~ Function 2 » Text Value $aServer[4][7] = $GUI_UNCHECKED ;~ Server 4 » Function 2 » Check Value ;~ Server 5 Array Info $aServer[5][0] = Null ;~ Reserved for Server 5 » Label Control Handle $aServer[5][1] = "ServerName5" ;~ Server 5 » Label Text Value $aServer[5][2] = Null ;~ Reserved for Server 5 » Function 1 » Control Handle $aServer[5][3] = "Function 1" ;~ Function 1 » Text Value $aServer[5][4] = $GUI_UNCHECKED ;~ Server 5 » Function 1 » Check Value $aServer[5][5] = Null ;~ Reserved for Server 5 » Function 2 » Control Handle $aServer[5][6] = "Function 2" ;~ Function 2 » Text Value $aServer[5][7] = $GUI_UNCHECKED ;~ Server 5 » Function 2 » Check Value #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 437, 192, 124) ;~ Server 1 Controls $aServer[1][0] = GUICtrlCreateLabel($aServer[1][1], 150, 72, 100, 17) $aServer[1][2] = GUICtrlCreateCheckbox($aServer[1][3], 288, 72, 97, 17) GUICtrlSetState(-1, $aServer[1][4]) $aServer[1][5] = GUICtrlCreateCheckbox($aServer[1][6], 392, 72, 97, 17) GUICtrlSetState(-1, $aServer[1][7]) ;~ Server 2 Controls $aServer[2][0] = GUICtrlCreateLabel($aServer[2][1], 150, 95, 100, 17) $aServer[2][2] = GUICtrlCreateCheckbox($aServer[2][3], 288, 96, 97, 17) GUICtrlSetState(-1, $aServer[2][4]) $aServer[2][5] = GUICtrlCreateCheckbox($aServer[2][6], 392, 96, 97, 17) GUICtrlSetState(-1, $aServer[2][4]) ;~ Server 3 Controls $aServer[3][0] = GUICtrlCreateLabel($aServer[3][1], 150, 119, 100, 17) $aServer[3][2] = GUICtrlCreateCheckbox($aServer[3][3], 288, 120, 97, 17) GUICtrlSetState(-1, $aServer[3][4]) $aServer[3][5] = GUICtrlCreateCheckbox($aServer[3][6], 392, 120, 97, 17) GUICtrlSetState(-1, $aServer[3][7]) ;~ Server 4 Controls $aServer[4][0] = GUICtrlCreateLabel($aServer[4][1], 150, 144, 100, 17) $aServer[4][2] = GUICtrlCreateCheckbox($aServer[4][3], 288, 144, 97, 17) GUICtrlSetState(-1, $aServer[4][4]) $aServer[4][5] = GUICtrlCreateCheckbox($aServer[4][6], 392, 144, 97, 17) GUICtrlSetState(-1, $aServer[4][7]) ;~ Server 5 Controls $aServer[5][0] = GUICtrlCreateLabel($aServer[5][1], 150, 170, 100, 17) $aServer[5][2] = GUICtrlCreateCheckbox($aServer[5][3], 288, 170, 97, 17) GUICtrlSetState(-1, $aServer[5][4]) $aServer[5][5] = GUICtrlCreateCheckbox($aServer[5][6], 392, 170, 97, 17) GUICtrlSetState(-1, $aServer[5][7]) $Start = GUICtrlCreateButton("Start", 240, 248, 147, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Start GUICtrlSetState($Start, $GUI_DISABLE) For $i = 1 To $aServer[0][0] ;~ Check Function 1 Checked If BitAND(GUICtrlRead($aServer[$i][2]), $GUI_CHECKED) = $GUI_CHECKED Then $aServer[$i][4] = $GUI_CHECKED Function1($aServer[$i][1]) Else $aServer[$i][4] = $GUI_UNCHECKED EndIf ;~ Check Function 2 Checked If BitAND(GUICtrlRead($aServer[$i][5]), $GUI_CHECKED) = $GUI_CHECKED Then $aServer[$i][7] = $GUI_CHECKED Function2($aServer[$i][1]) Else $aServer[$i][7] = $GUI_UNCHECKED EndIf Next GUICtrlSetState($Start, $GUI_ENABLE) EndSwitch WEnd Func Function1($_sServerName) MsgBox(4096, "Function 1", "Executing Function 1 for " & $_sServerName, 5) EndFunc Func Function2($_sServerName) MsgBox(4096, "Function 2", "Executing Function 2 for " & $_sServerName, 5) EndFunc aa2zz6 1
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