Im Input Enter anwenden

  • Hallo,
    es gibt in vielen Formen etc. ein Input wo man Enter drücken kann und es schikt ab.
    Wie kriege ich das mit AutoIt hin?
    Hotkeyset ist kacke, Ispressed geht aber wiederum ist es doof weil man ja nicht weiß ob man im Input ist bzw. sogar im welchen Input man ist.
    Wie bekomme ich das hin, aber OHNE Button ?

  • Es ist sehr simpel (geht auch im OnEventModus), aber hier ist erstmal ein Beispiel im GuiGetMsgmode:

    Spoiler anzeigen
    [autoit]

    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Enter im Inputfeld", 215, 100)
    $Label1 = GUICtrlCreateLabel("EnterCounter:", 8, 8, 69, 17)
    $Label2 = GUICtrlCreateLabel("0", 96, 8, 34, 17, $SS_CENTER)
    $Input1 = GUICtrlCreateInput("Tippe irgendwas und danach Enter", 8, 40, 193, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL))
    $Label3 = GUICtrlCreateLabel("Tippe EXIT und Enter -> Beenden", 16, 72, 165, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Input1
    If GUICtrlRead($Input1) = "Exit" Then Exit
    GUICtrlSetData($Input1,"")
    GUICtrlSetData($Label2,Execute(GUICtrlRead($Label2)+1))

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

    EndSwitch
    WEnd

    [/autoit]

    Wer immer nur das tut, was er bereits kann - wird auch immer nur das bleiben, was er bereits ist!

  • Wahlweise AdlibRegister und eine Function

    Spoiler anzeigen
    [autoit]


    #include <WinAPI.au3>

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

    AdlibRegister("_CheckFocus", 10)

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

    Func _CheckFocus()
    $hControl = GUICtrlGetHandle($Input) ;anpassen
    If _WinAPI_GetFocus() = $hControl Then
    If _IsPressed('0D') Then
    ;tu was
    EndIf
    EndIf
    EndFunc

    [/autoit]
  • [autoit]

    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    $Form1 = GUICreate("Form1", 143, 44, 192, 139)
    $Input1 = GUICtrlCreateInput("Input1", 8, 8, 121, 21)
    $Enter = GUICtrlCreateDummy()
    Dim $Array[1][2] = [["{ENTER}", $Enter]]
    GUISetAccelerators($Array)
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Enter
    $Ctrl = ControlGetFocus($Form1)
    If $Ctrl = "Edit1" Then
    $Value = ControlGetText($Form1, "", $Ctrl)
    MsgBox(0, "", "Die Eingabe in Input1 war: " & $Value)
    EndIf
    EndSwitch
    WEnd

    [/autoit]
  • Danke euch beiden :)
    Das von XovoxKingdom gefält mir etwas mehr da es weniger Code ist. Aber wenn man mehrfach Enter drücken will dann muss man jedesmal den Inhalt ändern.
    Und das von Pingui ist auch recht gut aber wenn ich bei ";tu was" eine msg reinmache und das ok dann mit Enter weg drücke, dann löst er wieder das Enter aus ^^