Sign in to follow this  
Followers 0
SuperFlyChetGuy

Ok or Cancel not working

4 posts in this topic

I have created a button to either press OK to continue or CANCEL to quit but pressing CANCEL doesn't quit. Yes I am a n00b to all this so did I miss some code that tells it "if cancel is pressed then end" ?

If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox(1,"","This is my message!" & @CRLF & "If you do not wish to proceed with removing these files please" & @CRLF & "press the CANCEL button now.")
Select
    Case $iMsgBoxAnswer = 1;OK

    Case $iMsgBoxAnswer = 2;Cancel

EndSelect

The SuperFlyChetGuy

Share this post


Link to post
Share on other sites



I have created a button to either press OK to continue or CANCEL to quit but pressing CANCEL doesn't quit. Yes I am a n00b to all this so did I miss some code that tells it "if cancel is pressed then end" ?

If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox(1,"","This is my message!" & @CRLF & "If you do not wish to proceed with removing these files please" & @CRLF & "press the CANCEL button now.")
Select
    Case $iMsgBoxAnswer = 1;OK

    Case $iMsgBoxAnswer = 2;Cancel

EndSelect
You need to tell the script what to do when a particular button is clicked.

If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox(1,"","This is my message!" & @CRLF & "If you do not wish to proceed with removing these files please" & @CRLF & "press the CANCEL button now.")
Select
    Case $iMsgBoxAnswer = 1;OK
        MsgBox(0, "OK", "You clicked OK")

    Case $iMsgBoxAnswer = 2 ;Cancel
        Exit

EndSelect

Support bacteria; it's the only culture most people have.LxP's Learning to Script with AutoIt 3 - Excellent starting placeVolly's Links Page - Links to cool and useful scriptsAutoIt Wrappers - Valuater's AutoIt Wrappers post. Lots of good stuff.Support AutoIt - Make a donation here; I did.[size="2"]#include <Guinness.pint>[/size]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Yes you are missing the code to tell the script what to do when those conditions are true. Is there a reason why you're not looking at the example code in the Help file? Look at the example code (scroll to the bottom of the page) for Select(). Hope that makes sense :).

Edit: Ksmith247, you good you. Just remember there's a fine line between being a helper and an enabler of certain behaviors. Doing for someone what they are capable of doing for themselves is really a disservice.

Edited by ssubirias3

Share this post


Link to post
Share on other sites

Awesome! Thanks a bunch.

@ssubirias3 - I looked but maybe I was looking at the wrong help files as I do not recall seeing that clarified. I thank you for you input.


The SuperFlyChetGuy

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