ARozanski Posted October 20, 2008 Share Posted October 20, 2008 (edited) Hi - i have built a GUI with 44 checkboxes belonging to an array of 44 variables...and i want to build a 'switch' to check whenever each one is getting checked or unchecked...my problem is i don't want to build a 'switch' with 44 case options...is there any way around this??? i.e. I have an array ($Array) with 44 variables each one of them checkboxes... While 1 $nMsg = GuiGetMsg() Switch $nMsg Case $Array[1] ....... Case $Array[2] ...... Case $Array[3] ...... Is there any ways around that?? Thank you in advance Edited October 20, 2008 by ARozanski Link to comment Share on other sites More sharing options...
dbzfanatic Posted October 20, 2008 Share Posted October 20, 2008 I did something like this a while back. I can't clearly remember what I did but I think it might've been something like this CODEWhile 1 $nMsg = GUIGetMsg() Switch $nMsg Case $array For $i = 0 To UBound($array) If $nMsg = $array[$i] Then MsgBox(0,"Number","You clicked box number: " & $i) Endif Next EndSwitch WEnd Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
ARozanski Posted October 20, 2008 Author Share Posted October 20, 2008 thanks so much!! Link to comment Share on other sites More sharing options...
dbzfanatic Posted October 20, 2008 Share Posted October 20, 2008 You're welcome . If that's what you were looking for please put "[RESOLVED]" in your title,that way anyone searching with the same problem can find the solution easier. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
ARozanski Posted October 20, 2008 Author Share Posted October 20, 2008 no problem - i am very new to AutoIt so i didnt know :-/ thanks again Link to comment Share on other sites More sharing options...
dbzfanatic Posted October 20, 2008 Share Posted October 20, 2008 We all start somewhere. It's not a rule but it's good practice to help people out and assuming people actually use the search feature could save someone a needless post. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
komalo Posted October 20, 2008 Share Posted October 20, 2008 (edited) also put this $nMsg >= $Array[1] And $nMsg <= $Array so it is going to loop every time a message happen since you use $array which is an empty variable and will causes the loop to run many times when you don't need it While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $nMsg >= $Array[1] And $nMsg <= $Array[44] For $i = 0 To UBound($array) If $nMsg = $array[$i] Then MsgBox(0, "Number", "You clicked box number: " & $i) EndIf Next EndSwitch WEnd Edited October 20, 2008 by komalo [font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font] Link to comment Share on other sites More sharing options...
dbzfanatic Posted October 20, 2008 Share Posted October 20, 2008 also put this $nMsg >= $Array[1] And $nMsg <= $Array so it is going to loop every time a message happen since you use $array which is an empty variable and will causes the loop to run many times when you don't need it While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $nMsg >= $Array[1] And $nMsg <= $Array[44] For $i = 0 To UBound($array) If $nMsg = $array[$i] Then MsgBox(0, "Number", "You clicked box number: " & $i) EndIf Next EndSwitch WEndHow is $array an empty variable? He said his array ($array) had 44 checkboxes. Last time I checked 44 was far from empty. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
komalo Posted October 20, 2008 Share Posted October 20, 2008 (edited) How is $array an empty variable? He said his array ($array) had 44 checkboxes. Last time I checked 44 was far from empty. try this #NoTrayIcon Global $Array[10] = [1,2,3,4,5,6,7,8,9,10] MsgBox("","Array",$Array) and that was your code While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $array For $i = 0 To UBound($array) If $nMsg = $array[$i] Then MsgBox(0,"Number","You clicked box number: " & $i) Endif Next EndSwitch WEnd Edited October 20, 2008 by komalo [font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font] Link to comment Share on other sites More sharing options...
dbzfanatic Posted October 20, 2008 Share Posted October 20, 2008 My example code. You have to realize this code will be added to more code and/or modified to suit the person's needs. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
rasim Posted October 20, 2008 Share Posted October 20, 2008 (edited) ARozanskiI think this be faster:#include <GuiConstantsEx.au3> Opt("GuiOnEventMode", 1) Global $aCheckbox[44] Dim $iLeft = 20, $iTop = 5 $hGUI = GUICreate("Test", 400, 300) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") For $i = 0 To UBound($aCheckbox) - 1 GUICtrlCreateCheckbox("Checkbox " & $i + 1, $iLeft, $iTop, 85, 20) GUICtrlSetOnEvent(-1, "_Check") $iLeft += 85 If $iLeft >= 350 Then $iLeft = 20 $iTop += 20 EndIf Next GUISetState() While 1 Sleep(100) WEnd Func _Check() ConsoleWrite(GUICtrlRead(@GUI_CtrlId, 1) & " Is checked = " & (GUICtrlRead(@GUI_CtrlId) = $GUI_CHECKED) & @LF) EndFunc Func _Exit() Exit EndFunc Edited October 20, 2008 by rasim 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