BitAnd

  • Hi ich versuche das zu verstehen aber kapiere nicht.
    Ich habe jetzt beim suchen das hier gefunden

    [autoit]

    If BitAND(GUICtrlRead($cb2), $GUI_CHECKED) Then

    [/autoit]


    Aber ich habe eben die funktion auch so getestet

    [autoit]

    If GUICtrlRead($cb2) = $GUI_CHECKED Then

    [/autoit]


    Beides funktioniert.
    jetzt wollte ich gern wissen was BitAND eig "dort" genau macht weil man daraus ja die gleiche funktion machen kann

  • Wenn du z.B. mit WinGetState den Wert 10 bekommst, dann brauchst du Bitand um herauszufinden, welche States es tatsächlich sind

    Schau dir mal folgendes Beispiel an:

    Spoiler anzeigen
    [autoit]

    Global $State

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

    GUICreate("", 200, 300)
    $CB_Start = GUICtrlCreateDummy()
    GUICtrlCreateCheckbox("Exists <1>", 10, 10)
    GUICtrlCreateCheckbox("Visible <2>", 10, 30)
    GUICtrlCreateCheckbox("Enabled <4>", 10, 50)
    GUICtrlCreateCheckbox("Active <8>", 10, 70)
    GUICtrlCreateCheckbox("Minimized <16>", 10, 90)
    GUICtrlCreateCheckbox("Maximized <32>", 10, 110)
    $CB_End = GUICtrlCreateDummy()
    $hState = GUICtrlCreateLabel("", 10, 140, 50, 20)
    $LB_Start = GUICtrlCreateDummy()
    GUICtrlCreateLabel("", 10, 170, 200, 20)
    GUICtrlCreateLabel("", 10, 190, 200, 20)
    GUICtrlCreateLabel("", 10, 210, 200, 20)
    GUICtrlCreateLabel("", 10, 230, 200, 20)
    GUICtrlCreateLabel("", 10, 250, 200, 20)
    GUICtrlCreateLabel("", 10, 270, 200, 20)
    $LB_End = GUICtrlCreateDummy()
    GUISetState()

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

    While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then Exit
    If $msg > $CB_Start And $msg < $CB_End Then
    $State = 0
    If GUICtrlRead($CB_Start + 1) = 1 Then $State = BitOR($State, 1)
    If GUICtrlRead($CB_Start + 2) = 1 Then $State = BitOR($State, 2)
    If GUICtrlRead($CB_Start + 3) = 1 Then $State = BitOR($State, 4)
    If GUICtrlRead($CB_Start + 4) = 1 Then $State = BitOR($State, 8)
    If GUICtrlRead($CB_Start + 5) = 1 Then $State = BitOR($State, 16)
    If GUICtrlRead($CB_Start + 6) = 1 Then $State = BitOR($State, 32)
    GUICtrlSetData($hState, "State: " & $State)
    GUICtrlSetData($LB_Start + 1, "BitAnd($State, 1): " & BitAND($State, 1))
    GUICtrlSetData($LB_Start + 2, "BitAnd($State, 2): " & BitAND($State, 2))
    GUICtrlSetData($LB_Start + 3, "BitAnd($State, 4): " & BitAND($State, 4))
    GUICtrlSetData($LB_Start + 4, "BitAnd($State, 8): " & BitAND($State, 8))
    GUICtrlSetData($LB_Start + 5, "BitAnd($State, 16): " & BitAND($State, 16))
    GUICtrlSetData($LB_Start + 6, "BitAnd($State, 32): " & BitAND($State, 32))
    EndIf
    WEnd

    [/autoit]

    lgE