Mintz Posted June 1, 2007 Posted June 1, 2007 I am currently making a scrpt with 2 MILLION differnt optoins$button1 = GUICtrlCreateButton("1", 10, 10, 60) $button2 = GUICtrlCreateButton("2", 10, 40, 60) $button3 = GUICtrlCreateButton("3", 10, 70, 60) $button4 = GUICtrlCreateButton("4", 10, 100, 60) $button5 = GUICtrlCreateButton("5", 10, 130, 60) $button6 = GUICtrlCreateButton("6", 10, 160, 60) $button7 = GUICtrlCreateButton("7", 10, 190, 60) $button8 = GUICtrlCreateButton("8", 10, 220, 60) $Radio1 = GUICtrlCreateRadio("1 ", 80, 10) $Radio2 = GUICtrlCreateRadio("2 ", 80, 40) $Radio3 = GUICtrlCreateRadio("3 ", 80, 70) $Radio4 = GUICtrlCreateRadio("4 ", 80, 100) $Radio5 = GUICtrlCreateRadio("5 ", 80, 130) $Radio6 = GUICtrlCreateRadio("6 ", 80, 160) $Radio7 = GUICtrlCreateRadio("7 ", 80, 190) $Radio8 = GUICtrlCreateRadio("8 ", 80, 220) $Checkbox1 = GUICtrlCreateCheckbox("1 ", 130, 10) $Checkbox2 = GUICtrlCreateCheckbox("2 ", 130, 40) $Checkbox3 = GUICtrlCreateCheckbox("3 ", 130, 70) $Checkbox4 = GUICtrlCreateCheckbox("4 ", 130, 100) $Checkbox5 = GUICtrlCreateCheckbox("5 ", 130, 130) $Checkbox6 = GUICtrlCreateCheckbox("6 ", 130, 160) $Checkbox7 = GUICtrlCreateCheckbox("7 ", 130, 190) $Checkbox8 = GUICtrlCreateCheckbox("8 ", 130, 220) I made that genaric so its easyer to read, but doing the math i have 8! x 60 which is a little over 2,500,000 differnt options. Any ideas on how to speed up writing this script?
BrettF Posted June 1, 2007 Posted June 1, 2007 (edited) For Loop.... Some math... Button 1-8: $x = 1 For $i = 10 to 220 Step 30 Assign ("Button"&$x, "GUICtrlCreateButton('"&$x&"', 10, "&$i&", 60)") $x += 1 Next I'm pretty sure this has been asked before. Take a look around in here, back a few pages. Edited June 1, 2007 by Bert Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
smashly Posted June 1, 2007 Posted June 1, 2007 Here's working example of creating controls in a loop to an array So you can see how to identify a controls in the arrays I also set a msgbox when a control is clicked .. There's more then 1 way to do what your after. #include <GUIConstants.au3> Global $Button[9], $Radio[9], $Checkbox[9] $Main = GUICreate("Controls", 165, 255) $y = 10 For $b = 1 To 8 $Button[$b] = GUICtrlCreateButton($b, 10, $y, 60) $Radio[$b] = GUICtrlCreateRadio($b & " ", 80, $y) $Checkbox[$b] = GUICtrlCreateCheckbox($b & " ", 130, $y) $y = $y + 30 Next GuiSetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect For $i = 1 To 8 Select Case $msg = $Button[$i] MsgBox(0,'Button ' & $i, 'Button ' & $i & ' was clicked', 1) Case $msg = $Radio[$i] MsgBox(0,'Radio ' & $i, 'Radio ' & $i & ' was selected', 1) Case $msg = $Checkbox[$i] If GUICtrlRead($Checkbox[$i]) = 1 Then MsgBox(0,'Checkbox ' & $i, 'Checkbox ' & $i & ' is checked', 1) Else MsgBox(0,'Checkbox ' & $i, 'Checkbox ' & $i & ' is unchecked', 1) EndIf EndSelect Next WEnd Even though this example is longer then what you posted , remeber this code actually runs.. Cheers
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