Combobox Hilfe! Eintrag einer ComboBox..

  • Hallo!

    Ich habe micht heute das erste mal mit AutoIT beschäftigt! Mir gefällt das Scripten sehr gut! Jedoch komme ich an diesem Punkt nicht weiter!

    Hier erstmal der Quellcode:

    [autoit]

    ; Programm starten Abfrage
    $answer = MsgBox(4, "Programm starten?", "Soll das Programm wirklich gestartet werden?")

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

    ; Ja, Nein

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

    If $answer = 7 Then
    MsgBox(0, "Programm starten?", "Das Programm wird nun beendet")
    Exit
    EndIf

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

    ; Windowsform erstellen
    #include <GUIConstants.au3>
    #Region ### START Koda GUI section ### Form=form1.kxf\form1.kxf
    $Form1_1 = GUICreate("Programm Starter", 282, 81, 324, 195)
    $Button1 = GUICtrlCreateButton("Starten", 160, 8, 113, 25, 0)
    $Button2 = GUICtrlCreateButton("Programm beenden", 88, 40, 113, 33, $BS_MULTILINE)
    $Combo = GUICtrlCreateCombo("", 8, 8, 137, 25, $CBS_DROPDOWNLIST)
    $Combo = GUICtrlSetData(-1,"calc.exe|cmd.exe|cleanmgr.exe|ipconfig.exe|devmgt.exe|dfrg.exe|dxdiag", "calc.exe")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

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

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

    Case $Button1
    run()
    Case $Button2
    Exit
    EndSwitch
    WEnd

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

    Ich möchte, dass er unter Case $Button1 bei run() das bei der ComboBox ausgewählte Programm startet!
    Vielen Dank für die Hilfe!

    euer
    projekt

    Einmal editiert, zuletzt von projekt (3. Juni 2008 um 21:04)

  • Kann man die nicht direkt über Run starten?? Also ohne kompletten Pfad?
    Wenn ja, die Combo über GUICtrlRead(id) auslesen und den Wert an den Run-Befehl übergeben.
    Beispiel:

    Code
    $a = GUICtrlRead($combo)
    Run($a)


    Außerdem kannst Du das $combo = bei $Combo = GUICtrlSetData(-1,"calc.exe|cmd.exe|cleanmgr.exe|ipconfig.exe|devmgt.exe|dfrg.exe|dxdiag", "calc.exe") weglassen, wenn ich mich nicht irre.

  • Hi,

    und herzlich Willkommen. Vielleicht hilft Dir ein Beispiel aus der "Hilfe" ? ;)

    Spoiler anzeigen
    [autoit]


    #include <GUIConstants.au3>

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

    GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered

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

    GUICtrlCreateCombo ("item1", 10,10) ; create first item
    GUICtrlSetData(-1,"item2|item3","item3") ; add other item snd set a new default

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

    GUISetState ()

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

    ; Run the GUI until the dialog is closed
    While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    Wend

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


    Weiterhin viel Erfolg !

  • Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    Opt("GUIOnEventMode", 1)
    GUICreate("combotest", 200, 200)
    $combo = GUICtrlCreateCombo("", 5, 5)
    GUICtrlSetData($combo, "|item1|item2")
    GUICtrlSetOnEvent($combo, "_comboread")
    GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
    GUISetState()

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

    While 1
    WEnd

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

    Func _comboread()
    $read = GUICtrlRead($combo)
    If $read = "item1" Then MsgBox(0, "Combobox", $read)
    If $read = "item2" Then MsgBox(0, "Combobox", $read)
    EndFunc

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

    Func _exit()
    Exit
    EndFunc

    [/autoit]


    is nich getestet aber sollte gehn ;)

    MFG FireFlyer

    *Paradox ist, wenn man sich im Handumdrehen den Fuss bricht* :D