Combobox Problem

  • Huhu AutoIT !

    Ich hab da wieder ein kleines Problem !
    Sieht euch einfach das Beispielscript an!
    Ziel: MsgBox mit der Nachricht was bei der Combobox ausgewählt wurde! also z.b. Test 2 wenn Test 2 ausgewählt wurde..

    Aber wenn ich bei den ??? $read einfüge sollte es doch eigentlich funktionieren, oder?


    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    Opt("GUIOnEventMode", 1)GUICreate("combotest", 200, 200)$map = GUICtrlCreateCombo("", 5, 5)GUICtrlSetData($Map, "|Test 1|Test 2|Test 3")GUICtrlSetOnEvent($map, "_comboread")$Button1 = GUICtrlCreateButton("Button1", 96, 120, 75, 25)
    GUISetState()While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitCase $Button1 MsgBox(0,"test",$??????) EndSwitchWEnd
    Func _comboread() $read = GUICtrlRead($map) If $read = "Test 1" Then MsgBox(0,"test","Test 1") If $read = "Test 2" Then MsgBox(0,"test","Test 2") If $read = "Test 3" Then MsgBox(0,"test","Test 3") EndFunc

    [/autoit]




    Danke schonmal im Vorraus!

  • Hier bitte

    Spoiler anzeigen
    [autoit]


    #include <GUIConstants.au3>
    $hGUI = GUICreate("combotest", 200, 200)
    $map = GUICtrlCreateCombo("", 5, 5)
    GUICtrlSetData($map, "|Test 1|Test 2|Test 3")
    $Button1 = GUICtrlCreateButton("Button1", 96, 120, 75, 25)
    GUISetState()
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    $var = GUICtrlRead($map)
    MsgBox(0, "Debug", $var)
    EndSwitch
    WEnd

    [/autoit]

    LG

    Philip

  • Funktioniert Super!
    Aber wie schaff ich da wenn man z.B. Test 1 Ausgewählt hab und als Msgbox das kommt: Msgbox(0 "Das erste"," Das erste") und wenn man Test 2 wählt: " (0,"Das zweite","Das zweite") usw.. da muss man doch wieder zu meinen Script oder, aber wo.ist das Problem bei mir?

    MfG

  • Dann kannst du es z.B. so machen :)

    [autoit]

    #include <GUIConstants.au3>$hGUI = GUICreate("combotest", 200, 200)$map = GUICtrlCreateCombo("", 5, 5)GUICtrlSetData($map, "|Test 1|Test 2|Test 3")$Button1 = GUICtrlCreateButton("Button1", 96, 120, 75, 25)GUISetState()While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $var = GUICtrlRead($map) If $var = "Test 1" Then MsgBox(0, "Debug", "Das erste") ElseIf $var = "Test 2" Then MsgBox(0, "Debug", "Das zweite") ElseIf $var = "Test 3" Then MsgBox(0, "Debug", "Das dritte") Else MsgBox(0, "Debug", "Irgendwas anderes") EndIf EndSwitchWEnd

    [/autoit]

    LG

    Philip

  • [autoit]


    GUICreate("Combo-Tut", 200, 80)
    $map = GUICtrlCreateCombo("", 0, 5)
    GUICtrlSetData($map, "|Test 1|Test 2|Test 3")
    $Button = GUICtrlCreateButton("Button", 100, 40, 75, 22)
    GUISetState()

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

    While True
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case -3 ;i $GUI_EVENT_CLOSE
    ExitLoop
    Case $Button
    ;i Example 1
    MsgBox(0, "1. Example", GUICtrlRead($map))
    ;i Example 2
    $var = GUICtrlRead($map)
    Switch $var
    Case "Test 1"
    $Msg = "Das Erste"
    Case "Test 2"
    $Msg = "Das Zweite"
    Case "Test 3"
    $Msg = "Das Dritte"
    Case Else
    $Msg = "Eine Eingabe ist erforderlich !"
    EndSwitch
    MsgBox(0, "2. Example", $Msg)
    EndSwitch
    WEnd
    ; Ende

    [/autoit]
  • Hmm.. Bei mir kommt da immernoch ein Fehler, bei dem Script..
    Ich bin mit der Entertaste nicht ganz klargekommen..
    Kannst du mir nochmal den Script senden, nur ohne [.autoit] [./autoit] sondern mit Spoiler ?
    Oder habe ich etwas dem Script falsch .. ?

    Spoiler anzeigen

    #include <ButtonConstants.au3>
    #include <ComboConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 615, 438, 192, 124)
    $Combo1 = GUICtrlCreateCombo("Combo1", 208, 72, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    GUICtrlSetData($Combo1, "|Test 1|Test 2|Test 3")
    $Button1 = GUICtrlCreateButton("Button1", 232, 128, 75, 25)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    $var = GUICtrlRead($Combo1)
    If $var = "Test 1" Then MsgBox(0, "Debug", "Das erste")
    ElseIf $var = "Test 2" Then MsgBox(0, "Debug", "Das zweite")
    ElseIf $var = "Test 3" Then MsgBox(0, "Debug", "Das dritte")
    Else MsgBox(0, "Debug", "Irgendwas anderes") EndIf

    EndSwitch
    WEnd