Selektieren nach Button!

  • Ich will also dass wenn ich einen Button drücke, dass dann das Input selektiert wird also mit selektieren mein ich so wie wenn ich auf den Input drücke!

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <ProgressConstants.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $i = 0
    $Form1 = GUICreate("SpeedWriteGame", 615, 129, 192, 124)
    $Input1 = GUICtrlCreateInput("", 56, 8, 545, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Label1 = GUICtrlCreateLabel("Eingabe:", 8, 8, 46, 17)
    $Label2 = GUICtrlCreateLabel("", 8, 40, 596, 36)
    GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Button1 = GUICtrlCreateButton("Pro", 8, 88, 83, 33)
    GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
    $Button2 = GUICtrlCreateButton("Noob", 96, 88, 75, 33)
    GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("Status:", 496, 104, 37, 17)
    $Label4 = GUICtrlCreateLabel("", 536, 104, 70, 17)
    $Label5 = GUICtrlCreateLabel("Punkte: " & $i ,546, 64, 70, 17)
    $Progress1 = GUICtrlCreateProgress(176, 88, 313, 33)
    AdlibRegister("_Status",250)
    AdlibRegister("_Wort",100)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    $Zufall = Random(1,44,1)
    $Wort = ""

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

    Func _Wort()
    $Zufall = Random(1,44,1)
    If $Zufall = 1 Then
    $Wort = "Ausgezeichnet"
    ElseIf $Zufall = 2 Then
    $Wort = "Autofahrer"
    ElseIf $Zufall = 3 Then
    $Wort = "Elektrizität"
    ElseIf $Zufall = 4 Then
    $Wort = "Wanduhr"
    ElseIf $Zufall = 5 Then
    $Wort = "Silvester"
    ElseIf $Zufall = 6 Then
    $Wort = "Haustelefon"
    ElseIf $Zufall = 7 Then
    $Wort = "Mobiltelefon"
    ElseIf $Zufall = 8 Then
    $Wort = "Computer"
    ElseIf $Zufall = 9 Then
    $Wort = "Fernseher"
    ElseIf $Zufall = 10 Then
    $Wort = "Brille"
    ElseIf $Zufall = 11 Then
    $Wort = "Rakete"
    ElseIf $Zufall = 12 Then
    $Wort = "Bombe"
    ElseIf $Zufall = 13 Then
    $Wort = "Benzin"
    ElseIf $Zufall = 14 Then
    $Wort = "Greenscreen"
    ElseIf $Zufall = 15 Then
    $Wort = "Gewicht"
    ElseIf $Zufall = 16 Then
    $Wort = "Haus"
    ElseIf $Zufall = 17 Then
    $Wort = "Tisch"
    ElseIf $Zufall = 18 Then
    $Wort = "Stuhl"
    ElseIf $Zufall = 19 Then
    $Wort = "Wand"
    ElseIf $Zufall = 20 Then
    $Wort = "Fahrrad"
    ElseIf $Zufall = 21 Then
    $Wort = "Boxer"
    ElseIf $Zufall = 22 Then
    $Wort = "Hund"
    ElseIf $Zufall = 23 Then
    $Wort = "Katze"
    ElseIf $Zufall = 24 Then
    $Wort = "Radio"
    ElseIf $Zufall = 25 Then
    $Wort = "Antenne"
    ElseIf $Zufall = 26 Then
    $Wort = "Bugatti"
    ElseIf $Zufall = 27 Then
    $Wort = "UASFNUI"
    ElseIf $Zufall = 28 Then
    $Wort = "INASFIN"
    ElseIf $Zufall = 29 Then
    $Wort = "ASFINUE"
    ElseIf $Zufall = 30 Then
    $Wort = "IANVASI"
    ElseIf $Zufall = 31 Then
    $Wort = "YKXCNA"
    ElseIf $Zufall = 32 Then
    $Wort = "OJFNEU"
    ElseIf $Zufall = 33 Then
    $Wort = "OAJSNA"
    ElseIf $Zufall = 34 Then
    $Wort = "ASNCIAS"
    ElseIf $Zufall = 35 Then
    $Wort = "KBOSAN"
    ElseIf $Zufall = 36 Then
    $Wort = "AIXNIANS"
    ElseIf $Zufall = 37 Then
    $Wort = "IOSJGFAF"
    ElseIf $Zufall = 38 Then
    $Wort = "INSADASC"
    ElseIf $Zufall = 39 Then
    $Wort = "UIENFAS"
    ElseIf $Zufall = 40 Then
    $Wort = "ICNAISN"
    ElseIf $Zufall = 41 Then
    $Wort = "ASINAIE"
    ElseIf $Zufall = 42 Then
    $Wort = "IASNVAI"
    ElseIf $Zufall = 43 Then
    $Wort = "IENFIAS"
    ElseIf $Zufall = 44 Then
    $Wort = "VNAISVA"
    EndIf
    EndFunc

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

    $Status = 0

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    AdlibUnRegister("_ZeitN")
    GUICtrlSetData($Progress1,100)
    GUICtrlSetData($Input1,"")
    $Status = 1
    GUICtrlSetData($Label2, $Wort)
    GUICtrlSetState($Input1, $GUI_ENABLE)
    AdlibRegister("_Zeit",25)
    Case $Button2
    AdlibUnRegister("_Zeit")
    GUICtrlSetData($Progress1,100)
    GUICtrlSetData($Input1,"")
    $Status = 1
    GUICtrlSetData($Label2, $Wort)
    GUICtrlSetState($Input1, $GUI_ENABLE)
    AdlibRegister("_ZeitN",100)
    EndSwitch
    WEnd

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

    Func _ZeitN()
    GUICtrlSetData($Progress1,GUICtrlRead($Progress1) - 1)
    If GUICtrlRead($Progress1) = 0 And $Status = 1 And GUICtrlRead($Input1) = GUICtrlRead($Label2) Then
    GUICtrlSetData($Label2, $Wort)
    GUICtrlSetData($Progress1,100)
    GUICtrlSetData($Input1,"")
    $i = $i + 1
    GUICtrlSetData($Label5,"Punkte: " & $i)
    ElseIf GUICtrlRead($Progress1) = 0 And $Status = 1 Then
    $Status = 0
    $i = 0
    GUICtrlSetData($Label5,"Punkte: " & $i)
    EndIf
    EndFunc

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

    Func _Zeit()
    GUICtrlSetData($Progress1,GUICtrlRead($Progress1) - 1)
    If GUICtrlRead($Progress1) = 0 And $Status = 1 And GUICtrlRead($Input1) = GUICtrlRead($Label2) Then
    GUICtrlSetData($Label2, $Wort)
    GUICtrlSetData($Progress1,100)
    GUICtrlSetData($Input1,"")
    $i = $i + Random(1,3,1)
    GUICtrlSetData($Label5,"Punkte: " & $i)
    ElseIf GUICtrlRead($Progress1) = 0 And $Status = 1 Then
    $Status = 0
    $i = 0
    GUICtrlSetData($Label5,"Punkte: " & $i)
    EndIf
    EndFunc

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

    Func _Status()
    If $Status = 0 Then
    GUICtrlSetData($Label4, "Nicht aktiv!")
    ElseIf $Status = 1 And GUICtrlRead($Input1) = GUICtrlRead($Label2) Then
    GUICtrlSetData($Label4, "Korrekt!")
    ElseIf $Status = 1 Then
    GUICtrlSetData($Label4, "Falsch!")
    EndIf
    EndFunc

    [/autoit]

    2 Mal editiert, zuletzt von Claiver (31. Dezember 2013 um 11:21)

    • Offizieller Beitrag

    Wie sehen deine Versuche dazu aus?

    • Offizieller Beitrag

    Schreib mal bitte, was du überhaupt willst?
    Welcher Button? Ist es deine GUI? Welches Input willst du selektieren? Dein eigenes? Das einer anderen GUI?
    Wo ist der Quellcode deiner GUI?

  • Schreib mal bitte, was du überhaupt willst?
    Welcher Button? Ist es deine GUI? Welches Input willst du selektieren? Dein eigenes? Das einer anderen GUI?
    Wo ist der Quellcode deiner GUI?

    Alsoo, Ich habe eine GUI wo ein Button und ein Input drinnen sind und halt noch mehr aber die spielen grad keine Rolle...
    Ich will dass wenn ich den Button drücke das dann das Input selektiert wird in der GUI, da es ein Geschwindigkeitsspiel werden soll, aber ich kein Lust hab nach dem Start immer erst auf den Button drücken. :S

    • Offizieller Beitrag

    Da du ja nicht deine Code zeigst, schau dir in der Hilfe

    [autoit]

    ControlFocus
    GUICtrlSetState

    [/autoit]


    an.

    Edit: Dein Code im 1. Post ist unleserlich. Wechsele mal in den Quellcode Modus und füge da dein Script ein.

    • Offizieller Beitrag

    Bei welchem Button soll beim klicken das Input selektiert werden?


    Edit:

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <ProgressConstants.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $i = 0
    $Form1 = GUICreate("SpeedWriteGame", 615, 129, 192, 124)
    $Input1 = GUICtrlCreateInput("", 56, 8, 545, 21)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Label1 = GUICtrlCreateLabel("Eingabe:", 8, 8, 46, 17)
    $Label2 = GUICtrlCreateLabel("", 8, 40, 596, 36)
    GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Button1 = GUICtrlCreateButton("Pro", 8, 88, 83, 33)
    GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
    $Button2 = GUICtrlCreateButton("Noob", 96, 88, 75, 33)
    GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("Status:", 496, 104, 37, 17)
    $Label4 = GUICtrlCreateLabel("", 536, 104, 70, 17)
    $Label5 = GUICtrlCreateLabel("Punkte: " & $i ,546, 64, 70, 17)
    $Progress1 = GUICtrlCreateProgress(176, 88, 313, 33)
    AdlibRegister("_Status",250)
    AdlibRegister("_Wort",100)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    $Zufall = Random(1,44,1)
    $Wort = ""

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

    Func _Wort()
    $Zufall = Random(1,44,1)
    If $Zufall = 1 Then
    $Wort = "Ausgezeichnet"
    ElseIf $Zufall = 2 Then
    $Wort = "Autofahrer"
    ElseIf $Zufall = 3 Then
    $Wort = "Elektrizität"
    ElseIf $Zufall = 4 Then
    $Wort = "Wanduhr"
    ElseIf $Zufall = 5 Then
    $Wort = "Silvester"
    ElseIf $Zufall = 6 Then
    $Wort = "Haustelefon"
    ElseIf $Zufall = 7 Then
    $Wort = "Mobiltelefon"
    ElseIf $Zufall = 8 Then
    $Wort = "Computer"
    ElseIf $Zufall = 9 Then
    $Wort = "Fernseher"
    ElseIf $Zufall = 10 Then
    $Wort = "Brille"
    ElseIf $Zufall = 11 Then
    $Wort = "Rakete"
    ElseIf $Zufall = 12 Then
    $Wort = "Bombe"
    ElseIf $Zufall = 13 Then
    $Wort = "Benzin"
    ElseIf $Zufall = 14 Then
    $Wort = "Greenscreen"
    ElseIf $Zufall = 15 Then
    $Wort = "Gewicht"
    ElseIf $Zufall = 16 Then
    $Wort = "Haus"
    ElseIf $Zufall = 17 Then
    $Wort = "Tisch"
    ElseIf $Zufall = 18 Then
    $Wort = "Stuhl"
    ElseIf $Zufall = 19 Then
    $Wort = "Wand"
    ElseIf $Zufall = 20 Then
    $Wort = "Fahrrad"
    ElseIf $Zufall = 21 Then
    $Wort = "Boxer"
    ElseIf $Zufall = 22 Then
    $Wort = "Hund"
    ElseIf $Zufall = 23 Then
    $Wort = "Katze"
    ElseIf $Zufall = 24 Then
    $Wort = "Radio"
    ElseIf $Zufall = 25 Then
    $Wort = "Antenne"
    ElseIf $Zufall = 26 Then
    $Wort = "Bugatti"
    ElseIf $Zufall = 27 Then
    $Wort = "UASFNUI"
    ElseIf $Zufall = 28 Then
    $Wort = "INASFIN"
    ElseIf $Zufall = 29 Then
    $Wort = "ASFINUE"
    ElseIf $Zufall = 30 Then
    $Wort = "IANVASI"
    ElseIf $Zufall = 31 Then
    $Wort = "YKXCNA"
    ElseIf $Zufall = 32 Then
    $Wort = "OJFNEU"
    ElseIf $Zufall = 33 Then
    $Wort = "OAJSNA"
    ElseIf $Zufall = 34 Then
    $Wort = "ASNCIAS"
    ElseIf $Zufall = 35 Then
    $Wort = "KBOSAN"
    ElseIf $Zufall = 36 Then
    $Wort = "AIXNIANS"
    ElseIf $Zufall = 37 Then
    $Wort = "IOSJGFAF"
    ElseIf $Zufall = 38 Then
    $Wort = "INSADASC"
    ElseIf $Zufall = 39 Then
    $Wort = "UIENFAS"
    ElseIf $Zufall = 40 Then
    $Wort = "ICNAISN"
    ElseIf $Zufall = 41 Then
    $Wort = "ASINAIE"
    ElseIf $Zufall = 42 Then
    $Wort = "IASNVAI"
    ElseIf $Zufall = 43 Then
    $Wort = "IENFIAS"
    ElseIf $Zufall = 44 Then
    $Wort = "VNAISVA"
    EndIf
    EndFunc

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

    $Status = 0

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    AdlibUnRegister("_ZeitN")
    GUICtrlSetData($Progress1,100)
    GUICtrlSetData($Input1,"")
    $Status = 1
    GUICtrlSetData($Label2, $Wort)
    GUICtrlSetState($Input1, $GUI_ENABLE)
    GUICtrlSetState($Input1, $GUI_FOCUS)
    AdlibRegister("_Zeit",25)
    Case $Button2
    AdlibUnRegister("_Zeit")
    GUICtrlSetData($Progress1,100)
    GUICtrlSetData($Input1,"")
    $Status = 1
    GUICtrlSetData($Label2, $Wort)
    GUICtrlSetState($Input1, $GUI_ENABLE)
    GUICtrlSetState($Input1, $GUI_FOCUS)
    AdlibRegister("_ZeitN",100)
    EndSwitch
    WEnd

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

    Func _ZeitN()
    GUICtrlSetData($Progress1,GUICtrlRead($Progress1) - 1)
    If GUICtrlRead($Progress1) = 0 And $Status = 1 And GUICtrlRead($Input1) = GUICtrlRead($Label2) Then
    GUICtrlSetData($Label2, $Wort)
    GUICtrlSetData($Progress1,100)
    GUICtrlSetData($Input1,"")
    $i = $i + 1
    GUICtrlSetData($Label5,"Punkte: " & $i)
    ElseIf GUICtrlRead($Progress1) = 0 And $Status = 1 Then
    $Status = 0
    $i = 0
    GUICtrlSetData($Label5,"Punkte: " & $i)
    EndIf
    EndFunc

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

    Func _Zeit()
    GUICtrlSetData($Progress1,GUICtrlRead($Progress1) - 1)
    If GUICtrlRead($Progress1) = 0 And $Status = 1 And GUICtrlRead($Input1) = GUICtrlRead($Label2) Then
    GUICtrlSetData($Label2, $Wort)
    GUICtrlSetData($Progress1,100)
    GUICtrlSetData($Input1,"")
    $i = $i + Random(1,3,1)
    GUICtrlSetData($Label5,"Punkte: " & $i)
    ElseIf GUICtrlRead($Progress1) = 0 And $Status = 1 Then
    $Status = 0
    $i = 0
    GUICtrlSetData($Label5,"Punkte: " & $i)
    EndIf
    EndFunc

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

    Func _Status()
    If $Status = 0 Then
    GUICtrlSetData($Label4, "Nicht aktiv!")
    ElseIf $Status = 1 And GUICtrlRead($Input1) = GUICtrlRead($Label2) Then
    GUICtrlSetData($Label4, "Korrekt!")
    ElseIf $Status = 1 Then
    GUICtrlSetData($Label4, "Falsch!")
    EndIf
    EndFunc

    [/autoit]

    Beim klicken beider Buttos wird der Focus auf das Ijnput gesetzt.

  • Da du ja nicht deine Code zeigst, schau dir in der Hilfe

    [autoit]

    ControlFocus
    GUICtrlSetState

    [/autoit]


    an.

    Edit: Dein Code im 1. Post ist unleserlich. Wechsele mal in den Quellcode Modus und füge da dein Script ein.


    Ok danke habs jetzt hinbekommen mit dem ControlFocus :D

    Edit1: Bei beiden :D

  • Meinst du das?

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 606, 70, 192, 124)
    $Input1 = GUICtrlCreateInput("Input1", 16, 16, 345, 21)
    $Button1 = GUICtrlCreateButton("Selektriere Inputbox", 368, 16, 121, 25)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    case $Button1
    GuiCtrlSetState($Input1,$Gui_Focus)
    EndSwitch
    WEnd

    [/autoit]


    Edit: Zu spät :S

    Sind TV-Quizfragen zu einfach? A) Ja B) Harry Potter

    Spoiler anzeigen

    Ich gebe zu dieser Post hat wahrscheinlich nicht viel geholfen,
    aber ich versuche wenigstens zu helfen :rolleyes:

    • Offizieller Beitrag

    Wenn dien Problem gelöst ist, setze den Thread auch auf gelöst. 1. Post editieren ;)