Sign in to follow this  
Followers 0
telco1800

MsgBox

10 posts in this topic

Okay, I just downloaded autoit. I'm a light programmer, but mostly networking and phonesystem speciallist. I love what I've seen so far of autoit, and I'm definately going to donate to the maker. However I've looked through the help, and I haven't found how to deal with the results of a msgbox. so say I use...

MsgBox(4, "whatever", "Do you want to install?")

How do I interperet the results. The help file has what the result codes are, but no example of using the result code. So if I wanted to do something like if result = 6 then continue, else end. How would I do that, what would the sytax look like?

Thank you everyone in advance, and I'm sorry if I duplicated a previous post, but I couldn't find it.

Telco1800

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

$ans = MsgBox(3, "AutoIt", "Yes - No - Cancel")

If $ans = 6 Then $var = "YES" ;yes

If $ans = 7 Then $var = "NO" ;no

If $ans = 2 Then Exit ;cancel

MsgBox(0, "AutoIt",$ans)

Edit: like I had a chance...

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

I'm a personal fan of Select over If Then statements, so taking herewasplato's example:

$ans = MsgBox(3,"AutoIt","Yes - No - Cancel")
Select
    Case $ans = 6
        $var = "YES"
    Case $ans = 7
        $var = "NO"
    Case $ans = 2
        Exit
EndSelect
MsgBox(0,"AutoIt",$ans)
They both work though.

Share this post


Link to post
Share on other sites

Thank you guys so much, your the heros for the day. lol

Share this post


Link to post
Share on other sites

Apologies for hijacking the thread, but W0uter, can you explain Switch to me (or perhaps send me a PM explaining it)? I tried to look it up in the Help file, but couldn't find it. Is it the same syntax as Select (Switch, Case, Case, Case Else, EndSwitch)?

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

switch is BETA only.

your code is 130 chars (w/o spaces)

with switch it could be 110 chars

also switch is a bit faster.

Switch MsgBox(3, "AutoIt", "Yes - No - Cancel")
    Case 6
        $var = "YES"
    Case 7
        $var = "NO"
    Case 2
        Exit
EndSwitch
MsgBox(0, "AutoIt", $ans)
Edited by w0uter

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Share this post


Link to post
Share on other sites

I tried to look it up in the Help file, but couldn't find it.

Keyword Reference

Switch...Case...EndSwitch

Look in the beta helpfile...


...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

Ah, that's why, I wasn't looking in the beta help file ;)

Thanks! I'll start giving it a shot in my scripts.

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  
Followers 0