Jump to content

SHould this function work?


 Share

Recommended Posts

Okay, i've got this function checking to see if a box is checked on the GUI, and if the box is checked it's suppose to Enable certain input fields. It just seems to me that my IF Statements might be wrong, because the GUICtrlSetState are correct.

Func UserCheck()
    
    
    If $Checkbox1 = $GUI_CHECKED Then
        GUICtrlSetState($Username2, $GUI_ENABLE)
        GUICtrlSetState($Password2, $GUI_ENABLE)
    EndIF
    
    If $Checkbox2 = $GUI_CHECKED Then
        GUICtrlSetState($Username3, $GUI_ENABLE)
        GUICtrlSetState($Password3, $GUI_ENABLE)
    EndIF
    
    If $Checkbox3 = $GUI_CHECKED Then
        GUICtrlSetState($Username4, $GUI_ENABLE)
        GUICtrlSetState($Password4, $GUI_ENABLE)
    EndIF
    
    If $Checkbox4 = $GUI_CHECKED Then
        GUICtrlSetState($Username5, $GUI_ENABLE)
        GUICtrlSetState($Password5, $GUI_ENABLE)
    EndIF
    
    If $Checkbox5 = $GUI_CHECKED Then
        GUICtrlSetState($Username6, $GUI_ENABLE)
        GUICtrlSetState($Password6, $GUI_ENABLE)
    EndIF
    
    If $Checkbox6 = $GUI_CHECKED Then
        GUICtrlSetState($Username7, $GUI_ENABLE)
        GUICtrlSetState($Password7, $GUI_ENABLE)
    EndIF
    
    If $Checkbox7 = $GUI_CHECKED Then
        GUICtrlSetState($Username8, $GUI_ENABLE)
        GUICtrlSetState($Password8, $GUI_ENABLE)
    EndIF
    
    If $Checkbox8 = $GUI_CHECKED Then
        GUICtrlSetState($Username9, $GUI_ENABLE)
        GUICtrlSetState($Password9, $GUI_ENABLE)
    EndIF
    
    If $Checkbox9 = $GUI_CHECKED Then
        GUICtrlSetState($Username10, $GUI_ENABLE)
        GUICtrlSetState($Password10, $GUI_ENABLE)
    EndIF
    
    If $Checkbox10 = $GUI_CHECKED Then
        GUICtrlSetState($Username11, $GUI_ENABLE)
        GUICtrlSetState($Password11, $GUI_ENABLE)
    EndIF
    
EndFunc
Link to comment
Share on other sites

No, but this should

If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then

I would also add an Else Statement in each along with GUICtrlGetState() (to minimize flickering)

If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
        If GUICtrlGetState($Username2) > 80 Then GUICtrlSetState($Username2, 80)
        If GUICtrlGetState($Password2) > 80 Then GUICtrlSetState($Password2, 80)
    Else
        If GUICtrlGetState($Username2) < 144 Then GUICtrlSetState( $Username2, 144) 
        If GUICtrlGetState($Password2) < 144 Then  GUICtrlSetState( $Password2, 144)
    EndIF

Edit: Syntax error

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Woot! Thank Alot! Works perfectly now!

Glad it worked. Remember that it's always better to check for state before setting state. Otherwise you will be back asking "Why do my controls flicker?".

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...