Jump to content
Sign in to follow this  

Case between

Recommended Posts

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]

Share this post

Link to post
Share on other sites

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.

Share this post

Link to post
Share on other sites


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)


While 1

    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
        Case $aButton[0] To $aButton[19]
            For $i = 0 To 19
                If $iMsg = $aButton[$i] Then
                    MsgBox(0, "Pressed", "Button " & $i)


Any help? :graduated:


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Share this post

Link to post
Share on other sites

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 :graduated:

Edited by rogue5099

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...