Jump to content
Sign in to follow this  
scriptomator

loop problem

Recommended Posts

scriptomator

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

Share this post


Link to post
Share on other sites
wakillon

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

Share this post


Link to post
Share on other sites
scriptomator

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.

Share this post


Link to post
Share on other sites
wakillon

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

Share this post


Link to post
Share on other sites
scriptomator

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

Share this post


Link to post
Share on other sites
wakillon

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

Share this post


Link to post
Share on other sites
scriptomator

well....time to do some script renovation. it should only take half an hour.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.