Mein Script funktioniert nicht.(Simpler 4 Ställiger Zahlen generator)

  • also ich ställ mir das so for
    man drückt button 1 ; eine box kommt mit irgendeiner zahl (1-9)
    dann drückt man button 2 : "
    bis Button 4

    und am ende stehen dann alle zahlen die man bekommen hat nebenein ander.

    [autoit]


    $S1 = GUICtrlCreateButton("Schritt 1", 10, 50, 50, 20)
    $S2 = GUICtrlCreateButton("Schritt 2", 20, 50, 50, 20)
    $S3 = GUICtrlCreateButton("Schritt 3", 50, 50, 50, 20)
    $S4 = GUICtrlCreateButton("Schritt 4", 100, 50, 50, 20)
    $Exit = GUICtrlCreateButton("Close", 200, 50, 50, 20)
    $Zahl = Random( 1, 9, 1)

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

    GUISetState() ; display the GUI

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

    Do
    $msg = GUIGetMsg()

    Select
    Case $msg = $S1
    MsgBox(0,"Zahl","Deine Zahl ist:" $Zahl)

    Case $msg = $S2
    MsgBox(0,"Zahl","Deine 2 Zahl ist:" $Zahl)

    Case $msg = $S3
    MsgBox(0,"Zahl","Deine 3 Zahl ist:" $Zahl)

    Case $msg = $S4
    MsgBox(0,"Zahl","Deine letzte Zahl ist:" $Zahl)

    Case $msg = $Exit
    MsgBox(0,"Beendet!","Beendet!")

    EndSelect
    Until $msg = $GUI_EVENT_CLOSE or $msg = $Exit

    [/autoit]

    was habe ich falsch gemacht den script kann ich nicht zum laufen bringen HELp

  • GUICreate fehlt. Und außerdem würde ich den Random mit in die Schleife packen, weil du fragst den ja am Anfang an und gehst dann erst in die Schleife, d.h. $Zahl hat dauernd den selben Wert. Und außerdem fehlen die Includs.

  • Du hast #includes vergessen, keine GUICreate(), in den MsgBox'en fehlt ein & .....
    Ausserdem wird $Zahl bei dir immer gleich sein, egal welchen Button man drückt.

    [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    $gui = GUICreate("Form1", 330, 44, 254, 124)
    $1 = GUICtrlCreateButton("Button1", 8, 8, 75, 25, $WS_GROUP)
    $2 = GUICtrlCreateButton("Button2", 88, 8, 75, 25, $WS_GROUP)
    $3 = GUICtrlCreateButton("Button3", 168, 8, 75, 25, $WS_GROUP)
    $4 = GUICtrlCreateButton("Button4", 248, 8, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    MsgBox(0,"Beendet!","Beendet!")
    Exit
    Case $1
    MsgBox(0,"Zahl","Deine Zahl ist:" & Random( 1, 9, 1))
    Case $2
    MsgBox(0,"Zahl","Deine Zahl ist:" & Random( 1, 9, 1))
    Case $3
    MsgBox(0,"Zahl","Deine Zahl ist:" & Random( 1, 9, 1))
    Case $4
    MsgBox(0,"Zahl","Deine Zahl ist:" & Random( 1, 9, 1))
    EndSwitch
    WEnd

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