Combo-Feld mit Eingabetaste aktivieren? / erkennen Combo aktiv?

  • Hallo,
    ich hätte gerne die Übertragung der Daten vom Combofeld in das Inputfeld PER EINGABETASTE, sprich, wenn man etwas NEUES eingibt (z.B. 'Das ist neu') und dann die EINGABETASTE drückt, soll dieser Text in das Inputfeld übertragen werden.

    Hat jemand eine Idee?

    Spoiler anzeigen


    #include <GUIConstants.au3>

    $hauptfenster = GUICreate("My GUI",300,200)

    $combofeld = GUICtrlCreateCombo("Auswahl 1",10,10,200,20)
    GUICtrlSetData(-1,"Nr.2|test|noch mal test|Auswahl xyz")
    $combostart = GUICtrlCreateButton("Übertragen",220,10,60,20)

    $inputfeld = GUICtrlCreateInput("",10,50,200,20)

    GUISetState ()

    While 1
    $msg = GUIGetMsg()

    if $msg = $combofeld or $msg = $combostart then
    GUICtrlSetData($inputfeld,GUICtrlRead($combofeld))
    EndIf

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    Wend
    Exit

    Vielen Dank
    Viele Grüße
    Carsten

    Einmal editiert, zuletzt von Carsten (29. Juni 2008 um 16:54)

  • Heyho Carsten,
    vielleicht so:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #include <Misc.au3>
    $hauptfenster = GUICreate("My GUI", 300, 200)

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

    $combofeld = GUICtrlCreateCombo("Auswahl 1", 10, 10, 200, 20)
    GUICtrlSetData(-1, "Nr.2|test|noch mal test|Auswahl xyz")
    $combostart = GUICtrlCreateButton("Übertragen", 220, 10, 60, 20)

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

    $inputfeld = GUICtrlCreateInput("", 10, 50, 200, 20)
    GUISetState()

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

    While 1
    $msg = GUIGetMsg()
    If _IsPressed("0D") Then
    If GUICtrlRead($combofeld) <> GUICtrlRead($inputfeld) Then GUICtrlSetData($inputfeld, GUICtrlRead($combofeld))
    EndIf
    If $msg = $combofeld Or $msg = $combostart Then
    GUICtrlSetData($inputfeld, GUICtrlRead($combofeld))
    EndIf

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

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    Exit

    [/autoit]
  • Hallo Blubbstar,

    vielen Dank für die schnelle Antwort. Es geht noch nicht ganz, da die Eingabetaste so ÜBERALL im GUI den Vorgang auslösen würde.
    (siehe Beispiel)
    Klappt nur, wenn ich auf die nächste Frage eine Lösung bekomme :)
    Wie kann ich erkennen, dass ein ComboFeld Aktiv ist ???

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #include <Misc.au3>
    $hauptfenster = GUICreate("My GUI", 300, 200)

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

    $combofeld = GUICtrlCreateCombo("Auswahl 1", 10, 10, 200, 20)
    GUICtrlSetData(-1, "Nr.2|test|noch mal test|Auswahl xyz")
    $combostart = GUICtrlCreateButton("Übertragen", 220, 10, 60, 20)

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

    $inputfeld = GUICtrlCreateInput("", 10, 50, 200, 20)

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

    $inputfeld2 = GUICtrlCreateInput("", 10, 80, 200, 20)

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

    GUISetState()

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

    While 1
    $msg = GUIGetMsg()
    ToolTip( GUICtrlGetState($combofeld)&" "&GUICtrlRead($combofeld)&" "&GUICtrlRecvMsg($combofeld,$EM_GETSEL))
    If $msg = $combofeld Or (_IsPressed("0D") ) Then
    GUICtrlSetData($inputfeld, GUICtrlRead($combofeld))
    EndIf

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

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    Exit

    [/autoit]

    Viele Grüße
    Carsten

  • Wenn du mit aktiv meinst das es den Fokus hat, dann kannst du einfach mit ControlGetFocus() überprüfen.

    Projekte: Keine größeren (und fertigen)
    Gegen Internetzensur:
    https://epetitionen.bundestag.de/index.php?acti…s;petition=3860
    (Zeichnungsfrist abgelaufen)
    __________________________________________________________________________________________________________________________________
    Dieser Beitrag wurde bereits 264 mal editiert, zuletzt von »Fast2« (30. Februar 2009, 12:99)

  • So einfach ist das auch nicht :P Aber hier ist eine möglichkeit:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #include <Misc.au3>
    $hauptfenster = GUICreate("My GUI", 300, 200)

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

    $combofeld = GUICtrlCreateCombo("Auswahl 1", 10, 10, 200, 20)
    GUICtrlSetData(-1, "Nr.2|test|noch mal test|Auswahl xyz")
    $combostart = GUICtrlCreateButton("Übertragen", 220, 10, 60, 20)

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

    $inputfeld = GUICtrlCreateInput("", 10, 50, 200, 20)

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

    $inputfeld2 = GUICtrlCreateInput("", 10, 80, 200, 20)

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

    ;Enter accelerator:
    $ENTERDummy = GUICtrlCreateDummy()
    Dim $accel[1][2] = [["{ENTER}",$ENTERDummy]]
    GUISetAccelerators($accel)

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

    GUISetState()

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

    While 1
    $msg = GUIGetMsg()
    If $msg = $combofeld Or $msg = $combostart Or ($msg = $ENTERDummy And ControlGetFocus(GUICtrlGetHandle($combofeld))="Edit1" ) Then
    GUICtrlSetData($inputfeld, GUICtrlRead($combofeld))
    EndIf

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

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    Exit

    [/autoit]