Rogue5099 Posted September 28, 2011 Share Posted September 28, 2011 I set up a GUI with buttons using For...Next and I am using a variable to find out which button was pressed. I have a previous examle that I used with the exact same thing but this time For...Next is starting at 65-90. In my previous atempt I used: Case $var[0], $var[1],$var[2],$var[3],$var[4] This time I am using the For $i = 65 to 90. How can I combine 65 through 90 without doing this: Case $var[65],$var[66],$var[67],$var[68],$var[69] so on....... looking for something like Case $var[65] through $var[90] My projects: Inventory / Mp3 Inventory, Computer Stats Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 28, 2011 Moderators Share Posted September 28, 2011 Case 65 To 90 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 28, 2011 Moderators Share Posted September 28, 2011 rogue5099, Perhaps like this: #include <GUIConstantsEx.au3> Global $aButton[20] $hGUI = GUICreate("Test", 500, 500) For $i = 0 To 19 $aButton[$i] = GUICtrlCreateButton($i, 10, 10 + ($i * 20), 30, 20) Next GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $aButton[0] To $aButton[19] For $i = 0 To 19 If $iMsg = $aButton[$i] Then MsgBox(0, "Pressed", "Button " & $i) ExitLoop EndIf Next EndSwitch WEnd Any help? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Rogue5099 Posted October 1, 2011 Author Share Posted October 1, 2011 (edited) Any help? That worked in a new script but it didn't work in my current script. The thing was that I created on certain buttons due to certain information. For my examplei was creating eject buttons for CDROM Drives on the computer. Using Chr() 65-90 (A-Z) you can create Eject buttons for drives that are only "CDROM" drives. Knowing that A:\ isn't a CDROM drive on most computers the For Loop wouldnt create the Control leaving $Drive[65] at 0. Then the GUIGetMsg() would be 0 if idle so in Switch..Case saying $Drive[65] which would be A:\ would be 0 since it was never created, hince keep going to Exitloop after first For $i = 65 To 90. What I ended up having to do is create all the buttons and then stringcompare("CDROM") <> 0 then set control hidden if not CDROM!!! I was close and I was trying "To" but it wasn't working. I'm glad I didn't have to post up script and I was able to figure this one out on my own!!!!! I'm learning!! Edit: 1 More thing is getting the Exact same results my script has went from 1498 lines to 584 lines Edited October 1, 2011 by rogue5099 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