Jump to content

How to create a message box with ok cancel


Recommended Posts

Hello, I am trying to create a simple message box with ok and cancel options. I have an autorun cd which runs an install with admin credentials but i want to give the option to cancel the installation. I cant figure out how to do this, I presume i need an if statement. can anyone help? Thanks

Link to comment
Share on other sites

  • Moderators

MsgBox(1, 'test', 'testing')

PS - Also in the helpfile under MsgBox()

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.

Link to comment
Share on other sites

Hello, I am trying to create a simple message box with ok and cancel options. I have an autorun cd which runs an install with admin credentials but i want to give the option to cancel the installation. I cant figure out how to do this, I presume i need an if statement. can anyone help? Thanks

You'll want to do something like this:

$prompt = msgbox(4129, "Continue?", "Click OK to auto run this CD or Cancel to exit now.")
if $prompt = "2" exit
<the rest of you code goes here>

I find the AutoIt Help Index very useful and I usually keep it open beside SciTE while coding. Look up the options for "MsgBox" and all the other powerful commands in AutoIt. Or use the online manual.

Link to comment
Share on other sites

thanks all for the replies. I tried all suggestions but they only gave me the box with options but didnt terminate the script. JustMeAgain's script worked fine. I did try the help as well but couldnt figure it out, but now it makes sense. Thanks again.

Edited by efjay
Link to comment
Share on other sites

  • Moderators

thanks all for the replies. I tried all suggestions but they only gave me the box with options but didnt terminate the script. JustMeAgain's script worked fine. I did try the help as well but couldnt figure it out, but now it makes sense. Thanks again.

If MsgBox(1, 'Test', 'Testing') = 2 Then Exit
Will Exit if the Cancel Button is Pressed, change it to 1 if you want it to exit when the OK button is pressed.

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.

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...