Opt("WinTitleMatchMode", "3")
Func _zml()
$chk = WinList()
For $i = 1 To $chk[0][0]
	If $chk[$i][0] <> "" And IsVisible($chk[$i][1]) Then
		$classes = StringSplit(_GetClasses($chk[$i][0]), @LF)
		For $z = 1 To $classes[0]
			If ControlCommand($chk[$i][0], "", $classes[$z], "IsEnabled", "") = 0 Then
				 ControlEnable($chk[$i][0], "", $classes[$z])
			 EndIf
		 Next
	 EndIf
 Next
 
EndFunc


Func IsVisible($handle)
    If BitAND(WinGetState($handle), 2) Then
        Return 1
    Else
        Return 0
    EndIf
EndFunc   ;==>IsVisible

Func _GetClasses($title)
    ;Get array of each control
    Local $buttonCount = 0, $editCount = 0, $staticCount = 0, $i
    Local $classes = StringSplit(WinGetClassList($title), @LF)
    Local $classIDs[$classes[0] + 1]
    Local $count[1][2]
    $classIDs[0] = $classes[0]
    For $i = 1 To $classes[0]
        Select
            Case $classes[$i] = "Button"
                $buttonCount = $buttonCount + 1
                $classIDs[$i] = $classes[$i] & $buttonCount
            Case $classes[$i] = "Edit"
                $editCount = $editCount + 1
                $classIDs[$i] = $classes[$i] & $editCount
                $classes[$i] = "Input"
            Case $classes[$i] = "Static"
                $staticCount = $staticCount + 1
                $classIDs[$i] = $classes[$i] & $staticCount
                $classes[$i] = "Label"
            Case Else
                If StringStripWS($classes[$i], 3) <> "" Then
                    $back = _Name2Link($classes[$i], $count)
                    If $back = 0 Then
                        ReDim $count[UBound($count) + 1][2]
                        $count[UBound($count) - 1][0] = $classes[$i]
                        $count[UBound($count) - 1][1] = 1
                        $classIDs[$i] = $classes[$i] & 1
                    Else
                        $classIDs[$i] = $count[$back][0] & ($count[$back][1] + 1)
                        $count[$back][1] += 1
                    EndIf
                EndIf
        EndSelect
    Next
    Local $classIDs2[1]
    For $i = 1 To $classIDs[0]
        If StringStripWS($classIDs[$i], 3) <> "" Then
            ReDim $classIDs2[UBound($classIDs2) + 1]
            $classIDs2[UBound($classIDs2) - 1] = $classIDs[$i]
        EndIf
    Next

    ;Display the results
    Local $output = ""
    For $i = 1 To UBound($classIDs2) - 1
        $output = $output & $classIDs2[$i] & @LF
    Next
    Return $output
EndFunc   ;==>_GetClasses

Func _Name2Link($link, $LinkNames)
    $x = 0
    For $i = 1 To UBound($LinkNames, 1) - 1
        If $link = $LinkNames[$i][0] Then
            $x = $i
            ExitLoop
        EndIf
    Next
    Return $x
EndFunc   ;==>_Name2Link 