Sign in to follow this  
Followers 0
SteveO

Help Needed! Please.

12 posts in this topic

#1 ·  Posted (edited)

Ok, i've got this posting code, that is suppose to check the GUI. It works great for the first check, but when I update the checkboxes, specifically when I uncheck a box, it still outputs the code of the unchecked section.

I have the following function set to a hotkey, so this is really the only code along with the GUI.

So basically it works when I check the boxes initially, but it doesn't work when I uncheck a box.

Func Post()
    
        ;;Check the GUI
    $Message = GUICtrlRead($Edit1)
    $Random = GUICtrlRead($List1)
    $StartBB = GUICtrlRead($Input1)
    $EndBB = GUICtrlRead($Input2)
    $PostNumber = GUICtrlRead($Input3)
    $a1 = GUICtrlRead($Activate1)
    $a2 = GUICtrlRead($Activate2)
    $a3 = GUICtrlRead($Numberedbumps)
    
        ;; Output the correct option
    Select
    Case $a1 and $a2 and $a3 = $GUI_CHECKED
    Send($Message & "{ENTER}" & $Random  &$StartBB & " " & $PostNumber & $EndBB)
    
    Case $a1 and $a2 = $GUI_CHECKED 
    Send($Message & "{ENTER}" & $Random  )
        
    
    Case $a1 and $a3 = $GUI_CHECKED 
    Send($Message & $StartBB & " " & $PostNumber & $EndBB)
        
    
    Case $a2 and $a3 = $GUI_CHECKED 
    Send($Random & $StartBB & " " & $PostNumber & $EndBB)
        
    
    Case $a3 = $GUI_CHECKED
    Send($StartBB & $PostNumber & $EndBB)
    
    EndSelect
    
       ;;+1 to the post number
    GUICtrlSetData ($Input3, $PostNumber + 1)
EndFunc
Edited by SteveO

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try using this format:

CODE
Case BitAND($a1, $GUI_CHECKED) = $GUI_CHECKED
Edited by dalisuit

Share this post


Link to post
Share on other sites

Like this? Cause it didn't work.

Func Post()
    
    $Message = GUICtrlRead($Edit1)
    $Random = GUICtrlRead($List1)
    $StartBB = GUICtrlRead($Input1)
    $EndBB = GUICtrlRead($Input2)
    $PostNumber = GUICtrlRead($Input3)
    $a1 = GUICtrlRead($Activate1)
    $a2 = GUICtrlRead($Activate2)
    $a3 = GUICtrlRead($Numberedbumps)
    
    Select
    Case BitAND($a1 and $a2 and $a3, $GUI_CHECKED) = $GUI_CHECKED
    Send($Message & "{ENTER}" & $Random  &$StartBB & " " & $PostNumber & $EndBB)
    
    Case BitAND($a1 and $a2, $GUI_CHECKED) = $GUI_CHECKED
    Send($Message & "{ENTER}" & $Random  )
        
    Case BitAND($a1 and $a3, $GUI_CHECKED) = $GUI_CHECKED
    Send($Message & $StartBB & " " & $PostNumber & $EndBB)
        
    Case BitAND($a2 and $a3, $GUI_CHECKED) = $GUI_CHECKED
    Send($Random & $StartBB & " " & $PostNumber & $EndBB)
        
    Case BitAND($a3, $GUI_CHECKED) = $GUI_CHECKED
    Send($StartBB & $PostNumber & $EndBB)
    
    Case BitAND($a1, $GUI_CHECKED) = $GUI_CHECKED
    Send($StartBB & $PostNumber & $EndBB)
    
    EndSelect
    

    GUICtrlSetData ($Input3, $PostNumber + 1)
EndFunc

Share this post


Link to post
Share on other sites

Please explain in plain language what you meant by this line. I suspect you misunderstand what "AND" is doing in a boolean context:

Case $a1 and $a2 and $a3 = $GUI_CHECKED

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Please explain in plain language what you meant by this line. I suspect you misunderstand what "AND" is doing in a boolean context:

Case $a1 and $a2 and $a3 = $GUI_CHECKED

:)

Haha, if a1 and a2 and a3 are checked do the following.

Share this post


Link to post
Share on other sites

Haha, if a1 and a2 and a3 are checked do the following.

I was afraid of that. What you are getting is: "If ($a1 = True) AND ($a2 = True) AND ($a3 = True) AND ($GUI_CHECKED = True) Then"

Try this instead:

If BitAND($a1, $a2, $3, $GUI_CHECKED) Then

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Ok, so it works to a point. The problem being since it goes down and checks the other statements, it'll output more than once for each true statement.

If BitAND($a1, $a2, $a3, $GUI_CHECKED) Then
    Send($Message & "{ENTER}" & $Random  &$StartBB & " " & $PostNumber & $EndBB)
    Endif
    
    If BitAND($a1, $a2, $GUI_CHECKED) Then
    Send($Message & "{ENTER}" & $Random  )
    Endif
    
    If BitAND($a1, $a3, $GUI_CHECKED) Then
    Send($Message & $StartBB & " " & $PostNumber & $EndBB)
    EndIf
    
    If BitAND($a2, $a3, $GUI_CHECKED) Then
    Send($Random & $StartBB & " " & $PostNumber & $EndBB)
    EndIf

    If BitAND($a3, $GUI_CHECKED) Then
    Send($StartBB & $PostNumber & $EndBB)
    EndIf

    If BitAND($a1, $GUI_CHECKED) Then
    Send($StartBB & $PostNumber & $EndBB)
    EndIf

Share this post


Link to post
Share on other sites

Try this;

Select
    Case BitAND($a1, $a2, $a3, $GUI_CHECKED)
        Send($Message & "{ENTER}" & $Random  &$StartBB & " " & $PostNumber & $EndBB)
    
    Case BitAND($a1, $a2, $GUI_CHECKED)
        Send($Message & "{ENTER}" & $Random  )
        
    Case BitAND($a1, $a3, $GUI_CHECKED)
        Send($Message & $StartBB & " " & $PostNumber & $EndBB)
        
    Case BitAND($a2, $a3, $GUI_CHECKED)
        Send($Random & $StartBB & " " & $PostNumber & $EndBB)
        
    Case BitAND($a3, $GUI_CHECKED)
        Send($StartBB & $PostNumber & $EndBB)
        
    Case BitAND($a1, $GUI_CHECKED)
        Send($StartBB & $PostNumber & $EndBB)
EndSelect

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Share this post


Link to post
Share on other sites

Ok, so it works to a point. The problem being since it goes down and checks the other statements, it'll output more than once for each true statement.

If BitAND($a1, $a2, $a3, $GUI_CHECKED) Then
    Send($Message & "{ENTER}" & $Random  &$StartBB & " " & $PostNumber & $EndBB)
    Endif
    
    If BitAND($a1, $a2, $GUI_CHECKED) Then
    Send($Message & "{ENTER}" & $Random  )
    Endif
    
    If BitAND($a1, $a3, $GUI_CHECKED) Then
    Send($Message & $StartBB & " " & $PostNumber & $EndBB)
    EndIf
    
    If BitAND($a2, $a3, $GUI_CHECKED) Then
    Send($Random & $StartBB & " " & $PostNumber & $EndBB)
    EndIf

    If BitAND($a3, $GUI_CHECKED) Then
    Send($StartBB & $PostNumber & $EndBB)
    EndIf

    If BitAND($a1, $GUI_CHECKED) Then
    Send($StartBB & $PostNumber & $EndBB)
    EndIf
Then it did exactly what you told it to do in the code above. What did you mean for it to do, in plain language?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Then it did exactly what you told it to do in the code above. What did you mean for it to do, in plain language?

:)

From what I understand he wants it to do the following;

Only If a1, a2 and a3 are checked, then send message1

Only If a1 and a2 are checked, but not a3, then send message2

Only If a1 and a3 are checked, but not a2, send message3

...

etc

That's why I offered a Select...Case...EndSelect option rather than a long If...ElseIf...Else....EndIf statement.

Edited by aslani

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Share this post


Link to post
Share on other sites

Try this;

Select
    Case BitAND($a1, $a2, $a3, $GUI_CHECKED)
        Send($Message & "{ENTER}" & $Random  &$StartBB & " " & $PostNumber & $EndBB)
    
    Case BitAND($a1, $a2, $GUI_CHECKED)
        Send($Message & "{ENTER}" & $Random  )
        
    Case BitAND($a1, $a3, $GUI_CHECKED)
        Send($Message & $StartBB & " " & $PostNumber & $EndBB)
        
    Case BitAND($a2, $a3, $GUI_CHECKED)
        Send($Random & $StartBB & " " & $PostNumber & $EndBB)
        
    Case BitAND($a3, $GUI_CHECKED)
        Send($StartBB & $PostNumber & $EndBB)
        
    Case BitAND($a1, $GUI_CHECKED)
        Send($StartBB & $PostNumber & $EndBB)
EndSelect
Perfect. Thanks everyone for your input on this issue. =)

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