Jump to content

MsgBox


Recommended Posts

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

Link to comment
Share on other sites

$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]

Link to comment
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.
Link to comment
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)?

Link to comment
Share on other sites

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

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