Jump to content

Recommended Posts

Posted

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
Posted

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]

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...