pcvodak Posted May 15, 2006 Posted May 15, 2006 I'm trying to figure out how to tell which button is clicked in a Yes/No MsgBox. I want some code to execute when the user clicks the Yes button. I already have a Gui running with other buttons on it and so I'm using a MsgBox. MsgBox(4, "Yes/No" "Some question the user needs to answer")
Moderators big_daddy Posted May 15, 2006 Moderators Posted May 15, 2006 I'm trying to figure out how to tell which button is clicked in a Yes/No MsgBox. I want some code to execute when the user clicks the Yes button. I already have a Gui running with other buttons on it and so I'm using a MsgBox. MsgBox(4, "Yes/No" "Some question the user needs to answer")First you need to assign a variable to the msgbox, like so: $var = MsgBox(4, "Yes/No" "Some question the user needs to answer") Then after the msgbox check the return value, like so: If $var = 1 Then MsgBox(0, "", 'You clicked "OK".') ElseIf $var = 2 Then MsgBox(0, "", 'You clicked "Cancel".') EndIf More return values can be found in the help file under MsgBox()
Moderators SmOke_N Posted May 15, 2006 Moderators Posted May 15, 2006 First you need to assign a variable to the msgbox, like so: $var = MsgBox(4, "Yes/No" "Some question the user needs to answer") Then after the msgbox check the return value, like so: If $var = 1 Then MsgBox(0, "", 'You clicked "OK".') ElseIf $var = 2 Then MsgBox(0, "", 'You clicked "Cancel".') EndIf More return values can be found in the help file under MsgBox()Just a side note, you don't need to store them in a variable if you are going to do an action right after based on whether one of the conditions are true or not. Example:If MsgBox(1, 'Info:', 'Just a test') = 1 Then MsgBox(0, "", 'You clicked "OK".') Else MsgBox(0, "", 'You clicked "Cancel".') EndIf 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now