Lights out

  • Hallo ich hab dieses Skript:

    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 633, 447, 192, 124)
    $knopf1 = GUICtrlCreateButton("Start", 16, 8, 57, 33, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Button2", 24, 64, 57, 57, $WS_GROUP)
    $Button3 = GUICtrlCreateButton("Button2", 82, 64, 57, 57, $WS_GROUP)
    $Button4 = GUICtrlCreateButton("Button2", 144, 58, 57, 57, $WS_GROUP)
    $Button5 = GUICtrlCreateButton("Button2", 205, 62, 57, 57, $WS_GROUP)
    $Button6 = GUICtrlCreateButton("Button2", 267, 65, 57, 57, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    $feld=0
    global $1, $2, $3, $4, $5=0
    global $counter=0
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    case $GUI_EVENT_CLOSE
    Exit
    case $knopf1
    $start=Timerinit()
    _random()
    case $button2
    If $1= true then
    $counter= $counter + 1
    guictrlsetbkcolor($button2, 0xFFFFFF)
    _random()
    else
    Beep(50, 1000)
    EndIf
    case $button3
    If $2= true then
    $counter= $counter + 1
    guictrlsetbkcolor($button3, 0xFFFFFF)
    _random()
    else
    Beep(50, 1000)
    EndIf
    case $button4
    If $3= true then
    $counter= $counter + 1
    guictrlsetbkcolor($button4, 0xFFFFFF)
    _random()
    else
    Beep(50, 1000)
    EndIf
    case $button5
    If $4= true then
    $counter= $counter + 1
    guictrlsetbkcolor($button5, 0xFFFFFF)
    _random()
    else
    Beep(50, 1000)
    EndIf
    case $button6
    If $5= true then
    $counter= $counter + 1
    guictrlsetbkcolor($button6, 0xFFFFFF)
    _random()
    else
    Beep(50, 1000)

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

    EndIf

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

    EndSwitch
    WEnd
    func _random()

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

    If $counter=10 then
    guictrlsetbkcolor($button2, 0xE01B4C)
    guictrlsetbkcolor($button3, 0xE01B4C)
    guictrlsetbkcolor($button4, 0xE01B4C)
    guictrlsetbkcolor($button5, 0xE01B4C)
    guictrlsetbkcolor($button6, 0xE01B4C)
    Msgbox(0, "", Timerdiff($start) )
    else
    $feld= random(1, 6)
    $floor= floor($feld)

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

    select
    case $floor=1
    guictrlsetbkcolor($button2, 0xE01B4C)
    local $2, $3, $4, $5= false
    $1=true

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

    case $floor=2
    guictrlsetbkcolor($button3, 0xE01B4C)
    local $1, $3, $4, $5= false
    $2=true

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

    case $floor=3
    guictrlsetbkcolor($button4, 0xE01B4C)
    local $2, $1, $4, $5= false
    $3=true
    case $floor=4

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

    guictrlsetbkcolor($button5, 0xE01B4C)
    local $2, $3, $1, $5= false
    $4=true
    case $floor=5

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

    guictrlsetbkcolor($button6, 0xE01B4C)
    local $2, $3, $4, $1= false
    $5=true
    endselect
    endif
    endfunc

    [/autoit]


    Man klickt alle Lichter so schnell wie möglich aus.
    Kann man das nicht leichter umsetzen, denn was ist wenn ich 300 felder zb hab?^^

    [align=center]Meine Werke mit der Irrlicht Engine
    AutoIt Picture Viewer Dreidimensionaler Bildbetrachter
    Mr Bubble 3D Neue Interpretation des Flashklassikers Bubble trouble

  • Wie Stayawayknight schn sagte, die ButtonID's in einem Array speichern und dann das einfärben so machen:

    [autoit]

    GUICtrlSetColor($aArray[Random(0, MAXINDEX,1 )], 0xE01B4C)

    [/autoit]