Enter/Return Taste gleiche Funktion wie OK Button & Variable

  • Hallöchen, ich habe zur Zeit folgendes Problem: Und zwar möchte ich, dass ein Tastendruck auf die Enter/Return Taste auf das gleiche Ergebnis hinausläuft. Außerdem habe ich noch das Problem, dass ich, wenn ich etwas in das Bearbeitungsfeld eingebe und es dann als Run Befehl starte cniht emine Eingabe, sondern "4" nimmt. Hier der Quellcode dazu:

    [autoit]

    ;Includings
    #include <GuiConstantsEx.au3>
    ;Starting Game Code
    Opt('MustDeclareVars', 1)
    _Main()
    ;Starting Minecraft
    Func _Main()
    ;Attributes
    Local $Name, $OK, $Cancel, $msg
    ;Patching to 0.6
    Run("Patch.bat")
    WinWaitClose("Battlecraft Patcher")
    ;Starting Minecraft with custom Name
    ;Create GUI
    GuiCreate("Name", 165, 75)
    GuiSetIcon("battlecraft.ico", 0)
    GuiCtrlSetColor(-1,0xffffff)
    GUISetState(@SW_SHOW)
    ;Instruction
    GuiCtrlCreateGroup("Spielername eingeben", 5, 5, 155, 65)
    ;Insterting Name
    $Name = GuiCtrlCreateInput("", 10, 20, 145, 20)
    ;OK & Cancel Button
    $OK = GuiCtrlCreateButton("OK", 10, 45, 70, 20, $BS_DEFPUSHBUTTON)
    $Cancel = GuiCtrlCreateButton("Abbrechen", 85, 45, 71, 20)
    While 1
    $msg = GUIGetMsg()
    Select
    ;Clicked on "X" Button
    Case $msg = $GUI_EVENT_CLOSE
    GUIDelete()
    Exit
    ;Clicked on "OK" Button
    Case $msg = $OK
    Run("java -Xms512m -Xmx1024M -cp ""bin\*"" -Djava.library.path=""bin\natives"" net.minecraft.client.Minecraft" & $Name)
    GUIDelete()
    Exit
    ;Clicked on "Cancel" Button
    Case $msg = $Cancel
    GUIDelete()
    Exit
    EndSelect
    WEnd
    EndFunc

    [/autoit]


    Das ganze ist für einen Minecraft Server namens Battlecraft bestimmt und wird dort als NameChanger benutzt, bzw. soll benutzt werden.

    Danke schonmal im Voraus für die Antowrten.

    Einmal editiert, zuletzt von Euden (2. September 2011 um 12:45)

  • Tut mir Leid, aber bin ein Noob. Wie jetzt zu Nooby? Weil wenn das "$BS_DEFPUSHPUTTON" drinnen ist startet das nciht mal mehr!

  • $BS_DEFPUSHBUTTON ist im include ButtonConstants.au3 enthalten, das steht auch in der Hilfe.

    Wie GUICtrlRead funktioniert, siehst du am besten an den Beispielen in der Hilfe, auch bei GUICtrlCreateInput.

  • Ah hab es jetzt hinbekommen. Jetzt müsste es nur noch irgendwie gehen, dass man automatisch im Input drinnen ist und nicht erst reinklicken muss :O Google + Hilfe hat nichts gebracht. Mittlerweile schaut das Ganze so aus:

    [autoit]

    ;Includings
    #include <GuiConstantsEx.au3>
    #Include <GuiListView.au3>
    #include <WindowsConstants.au3>
    #include <ButtonConstants.au3>
    ;Starting Game Code
    Opt('MustDeclareVars', 1)
    _Main()
    ;Starting Minecraft
    Func _Main()
    ;Attributes
    Local $Name, $OK, $Cancel, $msg
    ;Patching
    Run("Update.exe")
    WinWaitClose("Patcher")
    Sleep(1750)
    Run("Patch.bat")
    WinWaitClose("Battlecraft Patcher")
    Sleep(500)
    ;Starting Minecraft with custom Name
    ;Create GUI
    GuiCreate("Name", 165, 75)
    GuiSetIcon("battlecraft.ico", 0)
    GuiCtrlSetColor(-1,0xffffff)
    GUISetState(@SW_SHOW)
    ;Instruction
    GuiCtrlCreateGroup("Spielername eingeben", 5, 5, 155, 65)
    ;Insterting Name
    $Name = GuiCtrlCreateInput("", 10, 20, 145, 20)
    ;OK & Cancel Button
    $OK = GuiCtrlCreateButton("OK", 10, 45, 70, 20, $BS_DEFPUSHBUTTON)
    $Cancel = GuiCtrlCreateButton("Abbrechen", 85, 45, 71, 20)
    While 1
    $msg = GUIGetMsg()
    Select
    ;Clicked on "X" Button
    Case $msg = $GUI_EVENT_CLOSE
    GUIDelete()
    Exit
    Case $msg = $GUI_EVENT_CLOSE
    GUIDelete()
    Exit
    ;Clicked on "OK" Button
    Case $msg = $OK
    Run("java -Xms512m -Xmx1024M -cp ""bin\*"" -Djava.library.path=""bin\natives"" net.minecraft.client.Minecraft " & GUICtrlRead($Name))
    GUIDelete()
    Exit
    ;Clicked on "Cancel" Button
    Case $msg = $Cancel
    GUIDelete()
    Exit
    EndSelect
    WEnd
    EndFunc

    [/autoit]