Autoit zu langsam oder Fehler am Script

  • Hallo Leute.
    Ich mache grad so ein Reaktionsspiel.
    Dort sind 6 Buttons und in der Mitte wird eine Zahl angezeigt und dann muss man auf den entsprechenden Button drücken.
    Es ist also so, dass das Script jede Sekunde eine andre Zahl einsetzen muss. Ist es dann normal das das Programm laggt o.ä?

  • Ok. Ich habe erst Funktionen eigebaut das man nur 2 Buttons drücken muss.

    Spoiler anzeigen
    [autoit]

    #cs ----------------------------------------------------------------------------

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

    AutoIt Version: 3.3.4.0
    Author: myName

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

    Script Function:
    Template AutoIt script.

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

    #ce ----------------------------------------------------------------------------
    #include<GUIConstantsEx.au3>

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

    $hGUI = GUICreate("So schnell du kannst",300,400)
    $onebutton = GUICtrlCreateButton("1",10,10,100,100)
    $twobutton = GUICtrlCreateButton("2",180,10,100,100)
    $threebutton = GUICtrlCreateButton("3",10,130,100,100)
    $fourbutton = GUICtrlCreateButton("4",180,130,100,100)
    $fivebutton = GUICtrlCreateButton("5",10,260,100,100)
    $sixbutton = GUICtrlCreateButton("6",180,260,100,100)
    $label = GUICtrlCreateLabel("",133,160,30,40)
    $startbutton = GUICtrlCreateButton("Start",125,360,50,25)
    GUICtrlSetState($label,$GUI_HIDE)

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

    GUICtrlSetFont($onebutton,30)
    GUICtrlSetFont($twobutton,30)
    GUICtrlSetFont($threebutton,30)
    GUICtrlSetFont($fourbutton,30)
    GUICtrlSetFont($fivebutton,30)
    GUICtrlSetFont($sixbutton,30)
    GUICtrlSetFont($label,30)

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

    GUICtrlSetBkColor($twobutton,0xff0000)
    GUICtrlSetBkColor($onebutton,0xff000)
    GUICtrlSetBkColor($threebutton,0xfff000)
    GUICtrlSetBkColor($fourbutton,0xf0)
    GUICtrlSetBkColor($fivebutton,0xff7f00)
    GUICtrlSetBkColor($sixbutton,0x7f00ff)
    GUISetState()

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

    Do

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

    $r = Random(1,2,1)

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

    Check_1()

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

    Check_2()

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

    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    Exit

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

    Func Check_1()

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

    If $r = "1" Then
    GUICtrlSetState($label,$GUI_SHOW)
    GUICtrlSetData($label,"1")
    Sleep(500)
    GUICtrlSetState($label,$GUI_HIDE)
    Do
    Sleep(100)
    Until GUIGetMsg() = $onebutton Or GUIGetMsg() = $twobutton or GUIGetMsg() = $threebutton or GUIGetMsg() = $fourbutton or GUIGetMsg() = $fivebutton or GUIGetMsg() = $sixbutton
    EndIf

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

    EndFunc ;==> Check_1

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

    Func Check_2()

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

    If $r = "2" Then
    GUICtrlSetState($label,$GUI_SHOW)
    GUICtrlSetData($label,"2")
    Sleep(500)
    GUICtrlSetState($label,$GUI_HIDE)
    Do
    Sleep(100)
    Until GUIGetMsg() = $onebutton Or GUIGetMsg() = $twobutton or GUIGetMsg() = $threebutton or GUIGetMsg() = $fourbutton or GUIGetMsg() = $fivebutton or GUIGetMsg() = $sixbutton
    EndIf

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

    EndFunc ;==> Check_2

    [/autoit]
  • So, hab dein Code mal Neugeschrieben, da die Funktionen i.wie keinen Sinn hatten.
    Das GUI ist normal, aber die Funktionen funktionieren :D
    Das mit dem Hiden hab ich noch nicht gemacht.
    Code:

    Spoiler anzeigen
    [autoit]

    #cs ----------------------------------------------------------------------------

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

    AutoIt Version: 3.3.4.0
    Author: myName

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

    Script Function:
    Template AutoIt script.

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

    #ce ----------------------------------------------------------------------------
    #include<GUIConstantsEx.au3>
    Global $var

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

    $hGUI = GUICreate("So schnell du kannst",300,400)
    $onebutton = GUICtrlCreateButton("1",10,10,100,100)
    $twobutton = GUICtrlCreateButton("2",180,10,100,100)
    $threebutton = GUICtrlCreateButton("3",10,130,100,100)
    $fourbutton = GUICtrlCreateButton("4",180,130,100,100)
    $fivebutton = GUICtrlCreateButton("5",10,260,100,100)
    $sixbutton = GUICtrlCreateButton("6",180,260,100,100)
    $label = GUICtrlCreateLabel("",133,160,30,40)
    $startbutton = GUICtrlCreateButton("Start",125,360,50,25)

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

    GUICtrlSetFont($onebutton,30)
    GUICtrlSetFont($twobutton,30)
    GUICtrlSetFont($threebutton,30)
    GUICtrlSetFont($fourbutton,30)
    GUICtrlSetFont($fivebutton,30)
    GUICtrlSetFont($sixbutton,30)
    GUICtrlSetFont($label,30)

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

    GUICtrlSetBkColor($twobutton,0xff0000)
    GUICtrlSetBkColor($onebutton,0xff000)
    GUICtrlSetBkColor($threebutton,0xfff000)
    GUICtrlSetBkColor($fourbutton,0xf0)
    GUICtrlSetBkColor($fivebutton,0xff7f00)
    GUICtrlSetBkColor($sixbutton,0x7f00ff)
    GUISetState()

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

    While 1
    $msg = GUIGetMsg()
    Switch $msg
    Case -3
    Exit
    Case $startbutton
    _Startup()
    $var = _Startup()
    Case Else
    Check($var, $msg)
    EndSwitch
    WEnd

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

    Func _Startup()
    Local $rnd = Random(1, 6, 1)
    GUICtrlSetData($label, $rnd)
    Return $rnd
    EndFunc

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

    Func Check($iRightNum, $Button)
    Switch $Button
    Case $onebutton
    If $iRightNum = 1 Then
    _Startup()
    $var = _Startup()
    EndIf
    Case $twobutton
    If $iRightNum = 2 Then
    _Startup()
    $var = _Startup()
    EndIf
    Case $threebutton
    If $iRightNum = 3 Then
    _Startup()
    $var = _Startup()
    EndIf
    Case $fourbutton
    If $iRightNum = 4 Then
    _Startup()
    $var = _Startup()
    EndIf
    Case $fivebutton
    If $iRightNum = 5 Then
    _Startup()
    $var = _Startup()
    EndIf
    Case $sixbutton
    If $iRightNum = 6 Then
    _Startup()
    $var = _Startup()
    EndIf
    EndSwitch
    EndFunc

    [/autoit]

    MfG. PrideRage

    Meine Projekte:
    ClipBoard Manager (beendet)
    Gutes ClipBoard Verwaltungs Programm mit nützlichen Funktionen.

    HTML Creator (beendet)
    Nützliches Tool um schnell ein eigenes HTML Dokument zu erstellen.