Jump to content

Recommended Posts

Posted (edited)

Hi guys,

I have another question regarding AutoIT. I have the code below but it does not work. Could you please assist?

Func IsTheCheckboxChecked ($CB1, $CB2)
    If GUICtrlRead ($CB1) = 1 Then
        Return 1
    ElseIf GUICtrlRead ($CB2) = 1 Then
        Return 2
    ElseIf (GUICtrlRead ($CB1) = 1) And (GUICtrlRead ($CB2) = 1) Then
        Return 3
    EndIf
EndFunc
$Digital = GUICtrlCreateCheckbox("Digital", 480, 80, 73, 17)
$Physical = GUICtrlCreateCheckbox("Physical", 560, 80, 81, 17)

If IsTheCheckboxChecked($Digital, $Physical) = 1 Then
    $EnabledItemTypesText = "Enabled Item Types: Digital"
ElseIf IsTheCheckboxChecked($Digital, $Physical) = 2 Then
    $EnabledItemTypesText = "Enabled Item Types: Physical"
ElseIf IsTheCheckboxChecked($Digital, $Physical) = 3 Then
    $EnabledItemTypesText = "Enabled Item Types: Digital and Physical"
EndIf

However, when both are ticket the output is only Digital. If I select only the Physical, only Physical is displayed in the output...

Any ideas?

Thanks in advance!

Edited by PunkoHead
Posted (edited)

Put this first: ElseIf (GUICtrlRead ($CB1) = 1) And (GUICtrlRead ($CB2) = 1) Then

Put it before the single checks.  You need to evalute the doubles before the singles b/c you stop looking after you find a single.  How can it ever reach the doubles if it exits on a single?

Func IsTheCheckboxChecked ($CB1, $CB2)
    If (GUICtrlRead ($CB1) = 1) And (GUICtrlRead ($CB2) = 1) Then
        Return 3
    ElseIf GUICtrlRead ($CB1) = 1 Then
        Return 1
    ElseIf GUICtrlRead ($CB2) = 1 Then
        Return 2
    EndIf
EndFunc

 

Edited by Xandy

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...