Loop mit Liste?

  • Hallo,

    kann mir jemand sagen wie ich einen Loop mit einer Liste machen kann?
    Die Listeneinträge kann man frei anklicken.
    Es können also 2, 4, 8.... ausgewählt sein.

    Ich meine z.B. so:
    Msgbox Eintrag 01 gewählt
    Msgbox Eintrag 02 gewählt
    Msgbox fertig!

    [autoit]


    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GUIListBox.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    $Form1 = GUICreate("Form1", 287, 230, 232, 162)
    $List1 = GUICtrlCreateList("", 8, 28, 161, 149, BitOR($GUI_SS_DEFAULT_LIST,$LBS_MULTIPLESEL))
    GUICtrlSetData(-1, "Eintrag 01|Eintrag 02|Eintrag 03|Eintrag 04|Eintrag 05|Eintrag 06|Eintrag 07|Eintrag 08|Eintrag 09|Eintrag 10")
    $Label1 = GUICtrlCreateLabel("Bitte auswählen", 8, 8, 79, 17)
    $Start = GUICtrlCreateButton("Start", 180, 112, 75, 61)
    $Alle = GUICtrlCreateButton("Alle", 180, 32, 75, 25)
    $Keine = GUICtrlCreateButton("Keine", 180, 64, 75, 25)
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    Case $Start
    Case $Alle
    Case $Keine
    EndSwitch
    WEnd

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

    Habe im Forum das gefunden

    Spoiler anzeigen


    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>


    $Form1 = GUICreate("ListView-Test", 532, 280, 347, 164)
    $list = GUICtrlCreateListView("List ", 16, 16, 345, 209)
    GUICtrlCreateListViewItem("Test",$list)
    GUICtrlCreateListViewItem("Fest",$list)
    GUICtrlCreateListViewItem("Rest",$list)
    $Button1 = GUICtrlCreateButton("GetSelectedItem", 368, 64, 145, 25)
    GUISetState(@SW_SHOW)


    While Sleep(30)
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1

    _check()
    EndSwitch
    WEnd


    Func _check()
    $item = StringTrimRight(GUICtrlRead(guictrlread($list)),1)
    If $item = "" Then
    MsgBox(0,"Error","No Item selected!")
    Else
    MsgBox(0,"",$item)
    EndIf
    EndFunc


    Bringt mich leider nicht weiter.

    Was ich auch nicht weiß:
    Wie kann man alle selektieren oder keine?

    Viele Grüße
    Ilse ;)

    2 Mal editiert, zuletzt von Ilse (5. Januar 2011 um 13:19)

  • Hallo Ilse,

    Zitat

    _GUICtrlListBox_GetSelItems
    --------------------------------------------------------------------------------

    Füllt einen Puffer mit einem Array der markierten Items

    Quelle: Hilfe

    mfg autoBert

  • Hallo autoBert,

    bin so froh daß du dich meldest.
    Ich kann heute nicht mehr klar denken.

    Habe mir nochmals die Hilfe angesehen
    Klappt leider immer noch nicht. Bin am Ende...

    [autoit]


    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GUIListBox.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    $Form1 = GUICreate("Form1", 287, 230, 232, 162)
    $List1 = GUICtrlCreateList("", 8, 28, 161, 149, BitOR($GUI_SS_DEFAULT_LIST,$LBS_MULTIPLESEL))
    GUICtrlSetData(-1, "Eintrag 01|Eintrag 02|Eintrag 03|Eintrag 04|Eintrag 05|Eintrag 06|Eintrag 07|Eintrag 08|Eintrag 09|Eintrag 10")
    $Label1 = GUICtrlCreateLabel("Bitte auswählen", 8, 8, 79, 17)
    $Start = GUICtrlCreateButton("Start", 180, 112, 75, 61)
    $Alle = GUICtrlCreateButton("Alle", 180, 32, 75, 25)
    $Keine = GUICtrlCreateButton("Keine", 180, 64, 75, 25)
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    Case $Start
    $aItems = _GUICtrlListBox_GetSelItems($List1)
    For $iI = 1 To $aItems[0]
    If $iI > 1 Then $sItems &= ", "
    $sItems &= $aItems[$iI]
    Next
    MsgBox(4160, "Information", "Items Selected: " & $sItems)
    Case $Alle
    Case $Keine
    EndSwitch
    WEnd

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

    Grüße
    Ilse ;)

    • Offizieller Beitrag

    So:

    Spoiler anzeigen
    [autoit]


    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GUIListBox.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    $Form1 = GUICreate("Form1", 287, 230, 232, 162)
    $List1 = GUICtrlCreateList("", 8, 28, 161, 149, BitOR($GUI_SS_DEFAULT_LIST, $LBS_MULTIPLESEL))
    GUICtrlSetData(-1, "Eintrag 01|Eintrag 02|Eintrag 03|Eintrag 04|Eintrag 05|Eintrag 06|Eintrag 07|Eintrag 08|Eintrag 09|Eintrag 10")
    $Label1 = GUICtrlCreateLabel("Bitte auswählen", 8, 8, 79, 17)
    $Start = GUICtrlCreateButton("Start", 180, 112, 75, 61)
    $Alle = GUICtrlCreateButton("Alle", 180, 32, 75, 25)
    $Keine = GUICtrlCreateButton("Keine", 180, 64, 75, 25)
    GUISetState(@SW_SHOW)

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

    Global $sItems
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    Case $Start
    $aItems = _GUICtrlListBox_GetSelItems($List1)
    For $iI = 1 To $aItems[0]
    If $iI > 1 Then $sItems &= ", "
    $sItems &= $aItems[$iI]
    Next
    MsgBox(4160, "Information", "Items Selected: " & $sItems)
    Case $Alle
    _GUICtrlListBox_SelItemRange($List1, 0, _GUICtrlListBox_GetCount($List1))
    Case $Keine
    _GUICtrlListBox_SelItemRange($List1, 0, _GUICtrlListBox_GetCount($List1), False)
    EndSwitch
    WEnd

    [/autoit]
  • Und bei Case $Start war auch ein kleiner "Fehler". So wolltest du es doch oder?

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GUIListBox.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    $Form1 = GUICreate("Form1", 287, 230, 232, 162)
    $List1 = GUICtrlCreateList("", 8, 28, 161, 149, BitOR($GUI_SS_DEFAULT_LIST,$LBS_MULTIPLESEL))
    GUICtrlSetData(-1, "Eintrag 01|Eintrag 02|Eintrag 03|Eintrag 04|Eintrag 05|Eintrag 06|Eintrag 07|Eintrag 08|Eintrag 09|Eintrag 10")
    $Label1 = GUICtrlCreateLabel("Bitte auswählen", 8, 8, 79, 17)
    $Start = GUICtrlCreateButton("Start", 180, 112, 75, 61)
    $Alle = GUICtrlCreateButton("Alle", 180, 32, 75, 25)
    $Keine = GUICtrlCreateButton("Keine", 180, 64, 75, 25)
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    Case $Start
    $aItems = _GUICtrlListBox_GetSelItems($List1)
    $sItems = ""
    For $iI = 1 To $aItems[0]
    If $iI > 1 Then $sItems &= ", "
    $sItems &= _GUICtrlListBox_GetText($List1, $aItems[$iI])
    Next
    MsgBox(4160, "Information", "Items Selected: " & $sItems)
    Case $Alle
    Case $Keine
    EndSwitch
    WEnd

    [/autoit]
  • erstmal Danke!

    @ name22
    leider stimmt meine msgbox nicht.
    Wie kann ich immer nur einen Eintrag anzeigen lassen.
    Also der aktuelle im Loop

    [autoit]


    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GUIListBox.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    $Form1 = GUICreate("Form1", 287, 230, 232, 162)
    $List1 = GUICtrlCreateList("", 8, 28, 161, 149, BitOR($GUI_SS_DEFAULT_LIST,$LBS_MULTIPLESEL))
    GUICtrlSetData(-1, "Eintrag 01|Eintrag 02|Eintrag 03|Eintrag 04|Eintrag 05|Eintrag 06|Eintrag 07|Eintrag 08|Eintrag 09|Eintrag 10")
    $Label1 = GUICtrlCreateLabel("Bitte auswählen", 8, 8, 79, 17)
    $Start = GUICtrlCreateButton("Start", 180, 112, 75, 61)
    $Alle = GUICtrlCreateButton("Alle", 180, 32, 75, 25)
    $Keine = GUICtrlCreateButton("Keine", 180, 64, 75, 25)
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    Case $Start
    $aItems = _GUICtrlListBox_GetSelItems($List1)
    $sItems = ""
    For $iI = 1 To $aItems[0]
    If $iI > 1 Then $sItems &= ", "
    $sItems &= _GUICtrlListBox_GetText($List1, $aItems[$iI])

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

    MsgBox(4160, "Information", "Bearbeitet wird der Eintrag: " & $sItems)

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

    Next

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

    Case $Alle
    Case $Keine
    EndSwitch
    WEnd

    [/autoit]

    Grüße
    Ilse ;)

    2 Mal editiert, zuletzt von Ilse (5. Januar 2011 um 13:01)

  • ...ich hab's
    nach einer halben Stunde probieren
    ein Zeichen entfernt (&)

    [autoit]


    $sItems = _GUICtrlListBox_GetText($List1, $aItems[$iI])

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

    ich glaube irgendwann wird man wahnsinnig, oder? ?(

    Danke Oscar für deine Lösung.
    und natürlich die Tipps aller....

    Liebe Grüße
    Ilse ;)

    Einmal editiert, zuletzt von Ilse (5. Januar 2011 um 13:23)