Hilfe mit 2 Gui s

  • Ich habe volgendes vor will aber net klappen ;(

    Ich habe eine gui auf der gibt es einen button der eine neue gui aufmacht dann will ich auf dieser neun gui ein paar buttons aber wenn ich dann drauf drücke passiert nichts ka warum ?(

    achja und auf der zweiten gui einen button der nur gui 2 schliest

    bekomm es aber einfach net hin ;(


    [autoit]


    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    $Form1 = GUICreate("The Game", 633, 454, 193, 115)
    GUISetBkColor(0x0000FF)
    $Start = GUICtrlCreateButton("Start", 192, 280, 217, 97, 0)
    GUICtrlSetFont(-1, 25, 400, 0, "MS Sans Serif")
    $Pic1 = GUICtrlCreatePic("bsp1.jpg", 64, 40, 100, 100, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic2 = GUICtrlCreatePic("bsp2.jpg", 256, 40, 100, 100, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic3 = GUICtrlCreatePic("bsp3.jpg", 456, 40, 100, 100, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))

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

    $Form2 = GUICreate("The Game", 633, 454, 193, 115)
    GUISetBkColor(0x0000FF)
    GUICtrlSetFont(-1, 25, 400, 0, "")
    $1 = GUICtrlCreateButton("bsp", 232, 120, 153, 41, 0)
    $Label = GUICtrlCreateLabel("Game", 168, 24, 286, 41)
    GUICtrlSetFont(-1, 25, 400, 0, "MS Sans Serif")
    $2 = GUICtrlCreateButton("bsp", 232, 176, 153, 41)
    $3 = GUICtrlCreateButton("bsp", 232, 232, 153, 41)
    $Back = GUICtrlCreateButton("Zurück", 470, 400, 153, 41)
    GUISetState(@SW_SHOW, $Form1)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $Form1
    Switch $msg[0]
    Case $GUI_EVENT_CLOSE
    ExitLoop
    Case $Start
    GUISetState(@SW_HIDE, $Form1)
    GUISetState(@SW_SHOW, $Form2)
    EndSwitch
    Case $Form2
    Switch $msg[0]
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_SHOW, $Form1)
    GUISetState(@SW_HIDE, $Form2)
    ;Case $Back
    ; MsgBox(0, '', 'Button 2 geklickt')
    EndSwitch
    EndSwitch
    WEnd
    GUIDelete($Form1)
    GUIDelete($Form2)

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


    stimmt das so oder was ist falsch

    danke schonmal jetzt

    3 Mal editiert, zuletzt von zausel3112 (15. Dezember 2009 um 09:01)

  • Probiers mal so, kanns aber gerade nicht testen ;(

    Spoiler anzeigen
    [autoit]


    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    $Form1 = GUICreate("The Game", 633, 454, 193, 115)
    GUISetBkColor(0x0000FF)
    $Start = GUICtrlCreateButton("Start", 192, 280, 217, 97, 0)
    GUICtrlSetFont(-1, 25, 400, 0, "MS Sans Serif")
    $Pic1 = GUICtrlCreatePic("bsp1.jpg", 64, 40, 100, 100, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic2 = GUICtrlCreatePic("bsp2.jpg", 256, 40, 100, 100, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic3 = GUICtrlCreatePic("bsp3.jpg", 456, 40, 100, 100, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))

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

    $Form2 = GUICreate("The Game", 633, 454, 193, 115)
    GUISetBkColor(0x0000FF)
    GUICtrlSetFont(-1, 25, 400, 0, "")
    $1 = GUICtrlCreateButton("bsp", 232, 120, 153, 41, 0)
    $Label = GUICtrlCreateLabel("Game", 168, 24, 286, 41)
    GUICtrlSetFont(-1, 25, 400, 0, "MS Sans Serif")
    $2 = GUICtrlCreateButton("bsp", 232, 176, 153, 41)
    $3 = GUICtrlCreateButton("bsp", 232, 232, 153, 41)
    $Back = GUICtrlCreateButton("Zurück", 470, 400, 153, 41)
    GUISetState(@SW_SHOW, $Form1)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $msg = GUIGetMsg(1)

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

    Switch $msg[0]
    Case $Start
    GUISetState(@SW_HIDE, $Form1)
    GUISetState(@SW_SHOW, $Form2)
    Case $GUI_EVENT_CLOSE
    If $msg[1] = $Form1 Then ;Fenster 1 geschlossen
    ExitLoop
    Else ;Fenster 2 geschlossen
    GUISetState(@SW_SHOW, $Form1)
    GUISetState(@SW_HIDE, $Form2)
    EndIf
    Case $Back
    MsgBox(0, '', 'Button 2 geklickt')
    EndSwitch
    WEnd

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

    GUIDelete($Form1)
    GUIDelete($Form2)

    [/autoit]
  • Du hattest zwar die Struktur in der While Schleife für erweiterten GUIGetMsg-Mode schon drin, aber du hattest den erweiterten Modus nicht aktiviert. (GUIGetMsg(1) müsste es richtigerweise heißen). Außerdem hattest du eine Variable $msg[0], die aber $nMsg[0] hätte heißen müssen.

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    $Form1 = GUICreate("The Game", 633, 454, 193, 115)
    GUISetBkColor(0x0000FF)
    $Start = GUICtrlCreateButton("Start", 192, 280, 217, 97, 0)
    GUICtrlSetFont(-1, 25, 400, 0, "MS Sans Serif")
    $Pic1 = GUICtrlCreatePic("bsp1.jpg", 64, 40, 100, 100, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
    $Pic2 = GUICtrlCreatePic("bsp2.jpg", 256, 40, 100, 100, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
    $Pic3 = GUICtrlCreatePic("bsp3.jpg", 456, 40, 100, 100, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))

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

    $Form2 = GUICreate("The Game", 633, 454, 193, 115)
    GUISetBkColor(0x0000FF)
    GUICtrlSetFont(-1, 25, 400, 0, "")
    $1 = GUICtrlCreateButton("bsp", 232, 120, 153, 41, 0)
    $Label = GUICtrlCreateLabel("Game", 168, 24, 286, 41)
    GUICtrlSetFont(-1, 25, 400, 0, "MS Sans Serif")
    $2 = GUICtrlCreateButton("bsp", 232, 176, 153, 41)
    $3 = GUICtrlCreateButton("bsp", 232, 232, 153, 41)
    $Back = GUICtrlCreateButton("Zurück", 470, 400, 153, 41)
    GUISetState(@SW_SHOW, $Form1)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[1]
    Case $Form1
    Switch $nMsg[0]
    Case $GUI_EVENT_CLOSE
    ExitLoop
    Case $Start
    GUISetState(@SW_HIDE, $Form1)
    GUISetState(@SW_SHOW, $Form2)
    EndSwitch
    Case $Form2
    Switch $nMsg[0]
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_SHOW, $Form1)
    GUISetState(@SW_HIDE, $Form2)
    ;Case $Back
    ; MsgBox(0, '', 'Button 2 geklickt')
    Case $Back
    GUISetState(@SW_SHOW, $Form1)
    GUISetState(@SW_HIDE, $Form2)
    EndSwitch
    EndSwitch
    WEnd
    GUIDelete($Form1)
    GUIDelete($Form2)

    [/autoit]
  • Meine Lösung :

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    $Form1 = GUICreate("The Game", 633, 454, 193, 115)
    GUISetBkColor(0x0000FF)
    $Start = GUICtrlCreateButton("Start", 192, 280, 217, 97, 0)
    GUICtrlSetFont(-1, 25, 400, 0, "MS Sans Serif")
    $Pic1 = GUICtrlCreatePic("bsp1.jpg", 64, 40, 100, 100, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic2 = GUICtrlCreatePic("bsp2.jpg", 256, 40, 100, 100, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic3 = GUICtrlCreatePic("bsp3.jpg", 456, 40, 100, 100, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))

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

    $Form2 = GUICreate("The Game", 633, 454, 193, 115)
    GUISetBkColor(0x0000FF)
    GUICtrlSetFont(-1, 25, 400, 0, "")
    $1 = GUICtrlCreateButton("bsp", 232, 120, 153, 41, 0)
    $Label = GUICtrlCreateLabel("Game", 168, 24, 286, 41)
    GUICtrlSetFont(-1, 25, 400, 0, "MS Sans Serif")
    $2 = GUICtrlCreateButton("bsp", 232, 176, 153, 41)
    $3 = GUICtrlCreateButton("bsp", 232, 232, 153, 41)
    $Back = GUICtrlCreateButton("Zurück", 470, 400, 153, 41)
    GUISetState(@SW_SHOW, $Form1)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg($Form1)
    $msg = GUIGetMsg($Form2)
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Start
    GUISetState(@SW_SHOW, $Form2)
    GUISetState(@SW_HIDE, $Form1)
    EndSwitch
    Switch $msg
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_HIDE, $Form2)
    GUISetState(@SW_SHOW, $Form1)
    Case $Back
    GUISetState(@SW_HIDE, $Form2)
    GUISetState(@SW_SHOW, $Form1)
    Case $1
    ;blabla
    Case $2
    ;blabla
    Case $3
    ;blabla
    EndSwitch
    WEnd

    [/autoit]
  • @Calypso: Das wird so nur mäßig funktionieren. Das liegt am Verhalten von GUIGetMsg. Liefert GUIGetMsg einen leerstring zurück, so drosselt es die Hauptschleife. Wenn bei dir in der While Schleife nichts passiert, wird gleich doppelt gedrosselt. Deswegen wird deine Variante das Script ungemein verlangsamen, und die Buttons werden nur träge reagieren.

  • vielen vielen danke ;D geht super !!!


    noch ne kleine frage ich hab einen knopf und er soll dann Random 1-3 machen und dann ausgeben gewonnen verloren unendschieden geht auch gut aber nur einmal ? was fehlt

    [autoit]


    Case $Stein
    $Stein = Random(1,3,1)
    if $Stein = 1 Then
    MsgBox(1,"Ergebnis","Verloren")
    ElseIf $Stein = 2 Then
    MsgBox(1,"Ergebnis","Gewonnen")
    Else
    MsgBox(1,"Ergebnis","Unendschieden")
    EndIf

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


    also meldung kommt will wenn ich dann oke drücke aber nochmal draufdücken können und er soll wieder random 1-3 machen ...

    danke für die schnelle antwort ;)


    Ps: Ich lerne noch :thumbup:

    2 Mal editiert, zuletzt von zausel3112 (14. Dezember 2009 um 15:26)

  • Sollte so funktionieren. Bei mir tuts das zumindest! ;D

    [autoit]


    Case $Stein
    $ausgabe = Random(1,3,1)
    if $ausgabe = 1 Then
    MsgBox(1,"Ergebnis","Verloren")
    ElseIf $ausgabe = 2 Then
    MsgBox(1,"Ergebnis","Gewonnen")
    Else
    MsgBox(1,"Ergebnis","Unendschieden")
    EndIf

    [/autoit]

    MfG
    qixx

  • geht auch gut aber nur einmal

    und zwar funktioniert das ganze nur einmal, weil du $Stein, also die Variable, die die Control ID deines Buttons beinhaltet, mit einem neuen Wert überschreibst. Im prinzip sollte die Funktion danach mit einem der vorher erstellten Buttons oder Lables funktionieren.

    Hier mal ein Beispiel: Die Funktion startet zuerst, wenn man Button 3 drückt.
    Danach wird der Wert in $Button3 geändert. Nun funktioniert die Funktion nur noch wenn man Button 1 drückt. Da $Button3 nun eine andere Control ID als die des ursprünglichen Buttons beinhaltet (hoffe das war verständlich)

    Spoiler anzeigen
    [autoit]


    $hGUI = GUICreate("Button321",280,100)
    $Button1 = GUICtrlCreateButton("",20,30,70,25)
    GUICtrlSetData(-1,$Button1); Ich schreibe auf die Buttons die jeweiligen Control ID's (nur zum verständniss)
    $Button2 = GUICtrlCreateButton("",100,30,70,25)
    GUICtrlSetData(-1,$Button2); Ich schreibe auf die Buttons die jeweiligen Control ID's (nur zum verständniss)
    $Button3 = GUICtrlCreateButton("",180,30,70,25)
    GUICtrlSetData(-1,$Button3); Ich schreibe auf die Buttons die jeweiligen Control ID's (nur zum verständniss)
    GUISetState()

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

    While 1 * Sleep(10)
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $Button3
    MsgBox(0,"","Vorher: "&$Button3&", jetzt 3")
    $Button3 = 3
    Case -3
    Exit
    EndSwitch

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

    WEnd

    [/autoit]
  • danke hat sich erledigt ;D

    Einmal editiert, zuletzt von zausel3112 (15. Dezember 2009 um 08:55)