Sign in to follow this  
Followers 0
Reloaded

How to detect if a MsgBox OK or CANCEL button was pressed?

6 posts in this topic

Ok so i have this MsgBox

MsgBox(1, "Title", "Label")

How can i find out if OK or CANCEL was pressed that way i can stop and exit the loop or script when CANCEL is pressed.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

put variable infront msgbox an do

If $var = 1 then..

from help file

Return Value

Success: Returns the ID of the button pressed.

Failure: Returns -1 if the message box timed out.

Button Pressed Return Value

OK 1

CANCEL 2

ABORT 3

RETRY 4

IGNORE 5

YES 6

NO 7

TRY AGAIN ** 10

CONTINUE ** 11

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

$answer=MsgBox(1,"A","B")

Now $answer has the button ID, check helpfile for Msgbox:

Button Pressed Return Value

OK 1

CANCEL 2

ABORT 3

RETRY 4

IGNORE 5

YES 6

NO 7

TRY AGAIN ** 10

CONTINUE ** 11

Share this post


Link to post
Share on other sites

put variable infront msgbox an do

If $var = 1 then..

from help file

Ok thanks that worked!

Now here is what i have so far and if the button NO is pressed how can i stop the program from being exited because ExitLoop and Exit just closes the program.

$msgBox = MsgBox(4, "Title", "Label") ; i decided to change to a YES and NO so NO's ID = 7
  If $msgBox = 7 Then
    Exit ; how can i break out of this IF statement without closing the whole program?
  Else
    xfSkinVista()
  EndIf

Share this post


Link to post
Share on other sites

Hi,

just change your logic:

$msgBox = MsgBox(4, "Title", "Label") ; i decided to change to a YES and NO so NO's ID = 7 and YES = 6
If $msgBox = 6 Then
    xfSkinVista()
EndIf
;go on with further coding

;-))

Stefan

Share this post


Link to post
Share on other sites

Hi,

just change your logic:

$msgBox = MsgBox(4, "Title", "Label") ; i decided to change to a YES and NO so NO's ID = 7 and YES = 6
If $msgBox = 6 Then
    xfSkinVista()
EndIf
;go on with further coding

;-))

Stefan

Ooooh good idea :D

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