Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm currently trying to learn about scripting with AutoHotkey. I'm trying to create a script which when a checkbox is checked and you press the Confirm button it produces a MsgBox which result is changed by the checkboxes. For example the if the "You are green" checkbox is checked I'm trying to have a MsgBox pop-up telling you that you're green. If both are checked it would tell you that you're both green and blue. I'm having troubles finding examples and solutions, and would be very grateful if you could provide some help or a push in the right direction. Thanks.

Gui, Add, Checkbox, vIsBlue, Are you Blue?
Gui, Add, Checkbox, vIsGreen, Are you Green?
Gui, Add, Button, Default gConfirm, Confirm
Gui, Show
Return

Confirm:
{
Gui, Submit
if vIsBlue = 1
    MsgBox, You're Blue,, Blue
if vIsBoth = 1
    MsgBox, You're Blue and Green,, Blue and Green
if vIsGreen = 1
    MsgBox, You're Green,, Green
Return
}
share|improve this question
add comment

1 Answer

You are very close! When you declare the variables in the Gui commands ie vIsBlue, the variable name that is then called in the sub does not need the v in front of it. I also fixed your If statement logic by reordering and adding Else If statements.

Gui, Add, Checkbox, vIsBlue, Are you Blue?
Gui, Add, Checkbox, vIsGreen, Are you Green?
Gui, Add, Button, Default gConfirm, Confirm
Gui, Show
Return

Confirm:
    Gui, Submit
    if (IsBlue = 1) and (IsGreen = 1)
        MsgBox, You're Blue and Green,,, Blue and Green
    else if IsBlue = 1
        MsgBox, You're Blue,,, Blue
    else if IsGreen = 1
        MsgBox, You're Green,,, Green
    Return
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.