Jump to content

loop problem


Recommended Posts

i want the select loop to detect more than one variable with one case .

i dont know how to do it. i want the message box to happen only when one of the three buttons is pressed

$GUI = GUICreate("The box", 537, 396, -1, -1)
$1 = GUICtrlCreateButton("1", 1, 104, 27, 25)
$2 = GUICtrlCreateButton("2", 184, 104, 27, 25)
$3 = GUICtrlCreateButton("3", 114, 104, 27, 25)
GUISetState(@SW_SHOW)

Global $1,$2,$3


While 1
    $Msg = GUIGetMsg()
    Select

            case $Msg = $1 or $2 or $3
                MsgBox(0,"","yay it works")
            exit




    EndSelect
WEnd
Link to comment
Share on other sites

Try like this Posted Image

$GUI = GUICreate("The box", 537, 396, -1, -1)
$1 = GUICtrlCreateButton("1", 1, 104, 27, 25)
$2 = GUICtrlCreateButton("2", 184, 104, 27, 25)
$3 = GUICtrlCreateButton("3", 114, 104, 27, 25)
GUISetState(@SW_SHOW)

Global $1,$2,$3

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        case $1 
            MsgBox(0,"1","yay it works")
        case $2 
            MsgBox(0,"2","yay it works")
        case $3 
            MsgBox(0,"3","yay it works")
    EndSwitch
WEnd
Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

I don't want it like that. i have a lot of variables that will require the one function to run. the function will figure out what the variable is that needs changing. but the problem is that i do not wand to type all of that in and i do not want to make the script to large. making the one function run with one line of code but many different things to trigger it is what i want.

Link to comment
Share on other sites

I don't want it like that. i have a lot of variables that will require the one function to run. the function will figure out what the variable is that needs changing. but the problem is that i do not wand to type all of that in and i do not want to make the script to large. making the one function run with one line of code but many different things to trigger it is what i want.

Like this ?

$GUI = GUICreate("The box", 537, 396, -1, -1)
$1 = GUICtrlCreateButton("1", 1, 104, 27, 25)
$2 = GUICtrlCreateButton("2", 184, 104, 27, 25)
$3 = GUICtrlCreateButton("3", 114, 104, 27, 25)
GUISetState(@SW_SHOW)

Global $1,$2,$3

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        case $1, $2, $3
            MsgBox(0,"","yay it works")
    EndSwitch
WEnd

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

UGHHH. I am an idiot. i cant believe i did not try that. I something very close to that and it did not work so i moved on to another method. thanks! Posted Image

Glad to help you, and look switch function in helpfile :

Switch...Case...EndSwitch Conditionally run statements.

Switch <expression>

Case <value> [To <value>] [,<value> [To <value>] ...]

statement1

...

[Case <value> [To <value>] [,<value> [To <value>] ...]

statement2

...]

[Case Else

statementN

...]

EndSwitch

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...