GuiCtrl Type ermitteln

  • [autoit]

    #include <GUIConstants.au3>
    #include <WinAPI.au3>

    [/autoit][autoit][/autoit][autoit]

    #Region - GUI Create
    GUICreate("", 100,100)
    $idButton = GUICtrlCreateButton("button", 4,4,80, 30)
    $idLabel = GUICtrlCreateLabel("",4,40,80,30)
    GUICtrlSetData($idLabel, _WinAPI_GetClassName($idButton))
    #EndRegion

    [/autoit][autoit][/autoit][autoit]

    GUISetState(@SW_SHOW)

    [/autoit][autoit][/autoit][autoit]

    Do
    Sleep(100)
    Until GUIGetMsg() = -3

    [/autoit][autoit][/autoit][autoit][/autoit]
  • Eine Checkbox ist im Prinzip ein Button. In diesem Fall könntest du noch weiter durch die Styles des Controls differenzieren. Eine Checkbox trägt z.B. den Standardstil $BS_AUTOCHECKBOX.. Ich kann im Moment nur leider nicht überblicken, inwieweit sich dadurch wirklich alle Controls gezielt voneinander unterscheiden lassen.

  • Spoiler anzeigen
    [autoit]


    ; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
    ; #FUNCTION# =========================================================================================================
    ; Name...........: GUICtrlGetStyle
    ; Description ...: Retrieves the Styles/ExStyles value(s) of the control.
    ; Syntax.........: GUICtrlGetBkColor($iControlID)
    ; Parameters ....: $iControlID - A valid control ID.
    ; Requirement(s).: v3.3.2.0 or higher
    ; Return values .: Success - Returns an Array[2] = [Style, ExStyle] with the Styles/ExStyles value(s).
    ; Failure - Returns an Array with -1 as the 0 & 1 Index's.
    ; Author ........: guinness & additional information from Melba23.
    ; Example........; Yes
    ;=====================================================================================================================
    Func GUICtrlGetStyle($iControlID)
    Local $aArray[2] = [-1, -1], $aExStyle, $aStyle, $hControl = GUICtrlGetHandle($iControlID)
    $aStyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $hControl, "int", 0xFFFFFFF0)
    If Not @error Then
    $aArray[0] = $aStyle[0]
    EndIf
    $aExStyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $hControl, "int", 0xFFFFFFEC)
    If Not @error Then
    $aArray[1] = $aExStyle[0]
    EndIf
    Return $aArray
    EndFunc ;==>GUICtrlGetStyle

    [/autoit] [autoit][/autoit] [autoit]

    ; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
    ; #FUNCTION# =========================================================================================================
    ; Name...........: _GUICtrlGetStyle_Convert
    ; Description ...: Converts the Styles/ExStyles value(s) of the control to a Hex value.
    ; Syntax.........: _GUICtrlGetStyle_Convert(ByRef $aArray)
    ; Parameters ....: $aArray - A valid 1D Array with 2 Index's.
    ; Requirement(s).: v3.3.2.0 or higher
    ; Return values .: Success - Returns a converted Array[2] = [Style, ExStyle] with the Styles/ExStyles Hex value(s).
    ; Failure - Returns 0 with @error = 1 & @extended = 1
    ; Author ........: guinness & additional information from Melba23.
    ; Example........; Yes
    ;=====================================================================================================================
    Func _GUICtrlGetStyle_Convert(ByRef $aArray)
    If Not IsArray($aArray) Then
    Return SetError(1, 0, 0)
    EndIf
    $aArray[0] = Hex($aArray[0], 4)
    $aArray[1] = Hex($aArray[1], 8)
    Return 1
    EndFunc ;==>_GUICtrlGetStyle_Convert

    [/autoit] [autoit][/autoit] [autoit][/autoit]