Jump to content

Deselect all check boxes


xandout
 Share

Recommended Posts

I was wondering if there is a way to uncheck all check boxes in a window. Java by default tries to install either yahoo or msn toolbars, its different each time, and i would like to ensure that autoit unchecks any box on a particular screen. thank in advance

Link to comment
Share on other sites

#include <Constants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>

$hGUI = GUICreate('Test', 600, 300)
For $i = 1 To 10
    For $j = 1 To 10
        GUICtrlCreateCheckbox("Chk" & $i*$j, ($j-1)*50+20, ($i-1)*25+20)
        If Random(0, 1, 1) Then GUICtrlSetState(-1, $GUI_CHECKED)
    Next
Next

GUISetState()
Sleep(1000)
_UnCheckAll($hGUI)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

GUIDelete()
Exit

Func _UnCheckAll($hWnd)
    Local $hChild = _WinAPI_GetWindow($hWnd, $GW_CHILD)
    
    While $hChild
        If _WinAPI_GetClassName($hChild) = "Button" And BitAND(_WinAPI_GetWindowLong($hChild, $GWL_STYLE), $BS_CHECKBOX) Then ControlCommand($hWnd, "", $hChild, "UnCheck", "")
        $hChild = _WinAPI_GetWindow($hChild, $GW_HWNDNEXT)
    WEnd
EndFunc

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