Jump to content

Looping through controls


Recommended Posts

Hi

Can anyone show me how to perform looping through controls (check boxes in this case) ? I know that the code in visual basic is something like:

Dim I As Integer

For I = 1 To 4
Me.Controls("Checkbox" & I).Value = True
Next

But how to do it in autoIT ?

Edited by dvlkn
Link to comment
Share on other sites

Hi

Can anyone show me how to perform looping through controls (check boxes in this case) ? I know that the code in visual basic is something like:

Dim I As Integer

For I = 1 To 4
Me.Controls("Checkbox" & I).Value = True
Next

But how to do it in autoIT ?

This is one way to do it.

Hope it helps.

You are going to have to get to know the help file intimately.

; Modified Example of GUICtrlCreateCheckbox Function from Help 
#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $checkCN[5], $msg, $I
    GUICreate("My GUI Checkbox")  ; will create a dialog box that when displayed is centered
    GUISetState()
    
    For $I = 1 To 4    
        $checkCN[$I] = GUICtrlCreateCheckbox("CHECKBOX " & $I, 10, 10+($I*23), 120, 20)
        GUICtrlSetState($checkCN[$I],$GUI_CHECKED)
    Next
    
    GUICtrlSetState($checkCN[2],$GUI_UNCHECKED)          

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>Example
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...