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.ä?
Autoit zu langsam oder Fehler am Script
-
- [ offen ]
-
Bakku -
19. Februar 2010 um 20:35 -
Geschlossen -
Erledigt
-
-
Hi.
Poste doch erstmal dein Code, dann kann man dir besimmt helfen. -
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
[/autoit] [autoit][/autoit] [autoit]
Author: myNameScript Function:
[/autoit] [autoit][/autoit] [autoit]
Template AutoIt script.#ce ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]
#include<GUIConstantsEx.au3>$hGUI = GUICreate("So schnell du kannst",300,400)
[/autoit] [autoit][/autoit] [autoit]
$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)GUICtrlSetFont($onebutton,30)
[/autoit] [autoit][/autoit] [autoit]
GUICtrlSetFont($twobutton,30)
GUICtrlSetFont($threebutton,30)
GUICtrlSetFont($fourbutton,30)
GUICtrlSetFont($fivebutton,30)
GUICtrlSetFont($sixbutton,30)
GUICtrlSetFont($label,30)GUICtrlSetBkColor($twobutton,0xff0000)
[/autoit] [autoit][/autoit] [autoit]
GUICtrlSetBkColor($onebutton,0xff000)
GUICtrlSetBkColor($threebutton,0xfff000)
GUICtrlSetBkColor($fourbutton,0xf0)
GUICtrlSetBkColor($fivebutton,0xff7f00)
GUICtrlSetBkColor($sixbutton,0x7f00ff)
GUISetState()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
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
ExitFunc Check_1()
[/autoit] [autoit][/autoit] [autoit]If $r = "1" Then
[/autoit] [autoit][/autoit] [autoit]
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
EndIfEndFunc ;==> Check_1
[/autoit] [autoit][/autoit] [autoit]Func Check_2()
[/autoit] [autoit][/autoit] [autoit]If $r = "2" Then
[/autoit] [autoit][/autoit] [autoit]
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
EndIfEndFunc ;==> 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
Das mit dem Hiden hab ich noch nicht gemacht.
Code:Spoiler anzeigen
[autoit]#cs ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]AutoIt Version: 3.3.4.0
[/autoit] [autoit][/autoit] [autoit]
Author: myNameScript Function:
[/autoit] [autoit][/autoit] [autoit]
Template AutoIt script.#ce ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]
#include<GUIConstantsEx.au3>
Global $var$hGUI = GUICreate("So schnell du kannst",300,400)
[/autoit] [autoit][/autoit] [autoit]
$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)GUICtrlSetFont($onebutton,30)
[/autoit] [autoit][/autoit] [autoit]
GUICtrlSetFont($twobutton,30)
GUICtrlSetFont($threebutton,30)
GUICtrlSetFont($fourbutton,30)
GUICtrlSetFont($fivebutton,30)
GUICtrlSetFont($sixbutton,30)
GUICtrlSetFont($label,30)GUICtrlSetBkColor($twobutton,0xff0000)
[/autoit] [autoit][/autoit] [autoit]
GUICtrlSetBkColor($onebutton,0xff000)
GUICtrlSetBkColor($threebutton,0xfff000)
GUICtrlSetBkColor($fourbutton,0xf0)
GUICtrlSetBkColor($fivebutton,0xff7f00)
GUICtrlSetBkColor($sixbutton,0x7f00ff)
GUISetState()While 1
[/autoit] [autoit][/autoit] [autoit]
$msg = GUIGetMsg()
Switch $msg
Case -3
Exit
Case $startbutton
_Startup()
$var = _Startup()
Case Else
Check($var, $msg)
EndSwitch
WEndFunc _Startup()
[/autoit] [autoit][/autoit] [autoit]
Local $rnd = Random(1, 6, 1)
GUICtrlSetData($label, $rnd)
Return $rnd
EndFuncFunc Check($iRightNum, $Button)
[/autoit]
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
EndFuncMfG. PrideRage
-
Ok.
Danke.
Aber wieso haben denn meine Funktionen gar kein Sinn ergeben.
Ich fande es sie nicht mal so schlecht -
Es hat nich funktioniert bei mir, da kam nur 1 oder 2 mehr nicht.
-
Er hatte ja auch extra gesagt, dass er im Moment nur Random(1,2,1) eingestellt hat.
-
Genau das habe ich.
Is ja jetzt auch egal. Danke für die Hilfe!