Sign in to follow this  
Followers 0
efjay

How to create a message box with ok cancel

9 posts in this topic

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

Share this post


Link to post
Share on other sites



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

PS - Also in the helpfile under MsgBox()


[center]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.[/center]

Share this post


Link to post
Share on other sites

C:\Program Files\AutoIt3\Examples\GUI\Advanced\msgboxwizard.au3 is handy also. :o

Share this post


Link to post
Share on other sites

try

(MsgBox(1,"here your title", "here your text")

Share this post


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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Actually the examples pretty much answered my question, thanks for the heads up Joon :o

Share this post


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

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.

[center]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.[/center]

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Thanks SmOke_N, thats even clearer.

Edited by efjay

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