Sleep bei GUI

  • Ich habe immer Probleme mit dem Befehl sleep ;( Ich denke, dass es daran leigt, dass er simpel den ganzen Script Pausiert, ich hab mir ein paar Forenartikel durchgelesen aber nichts Gutes gefunden. Ich habe gadacht ich hab eine lösung aber es hat auch nicht geholfen ;( Vieleicht wisst ihr warum die GUI nicht reagiert

    Einmal editiert, zuletzt von jasper3108 (22. April 2012 um 01:12)

  • Jupp Zeile 17-20 ist falsch bzw. nutzlos

    [autoit]


    GUISetOnEvent($Pause, "_Pause")
    GUISetOnEvent($Button2, "_Resume")
    GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
    GUISetOnEvent($Button1, "_File")

    [/autoit]

    richtig wäre mit

    [autoit]


    Opt("GUIOnEventMode", 1)
    GUICtrlSetOnEvent($Pause, "_Pause")
    GUICtrlSetOnEvent($Button2, "_Resume")
    GUICtrlSetOnEvent($GUI_EVENT_CLOSE, "_exit")
    GUICtrlSetOnEvent($Button1, "_File")

    [/autoit]


    Und dann kann er aber wenn er GUIOnEventMode anstatt Switch/Case in der Hauptschleife benutzen will Zeile 54 - 67 rausschmeissen

    [autoit]

    While $1 = 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    _File()
    Case $Pause
    _SoundPause($CurrentSound)
    Case $Button2
    _SoundResume($CurrentSound)
    EndSwitch
    WEnd
    $line = 1

    [/autoit]

    und mit einem 3 Zeiler ersetzen

    [autoit]

    While 1
    Sleep(100)
    WEnd

    [/autoit]
  • Hier mal beide Modi im Vergleich.

    Spoiler anzeigen
    [autoit]


    #include <Sound.au3>

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

    Global $CurrentSound
    #region ### START Playlister GUI section ###
    GUICreate("Playlister", 283, 224, 634, 131)
    $lbl = GUICtrlCreateLabel("", 0, 104, 279, 17)
    $bn1 = GUICtrlCreateButton("Open", 48, 40, 75, 22)
    $bn2 = GUICtrlCreateButton("Play", 128, 152, 75, 22)
    $Pause = GUICtrlCreateButton("Break", 8, 152, 75, 22)
    $ckb = GUICtrlCreateCheckbox("Save", 160, 48, 97, 17)
    GUICtrlSetState(-1, 1)

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

    GUISetState(@SW_SHOW)
    #endregion ### END Playlister GUI section ###

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

    #region ### START Playlister Loop section ###
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case -3
    ExitLoop
    Case $bn1
    _File()
    Case $Pause
    MsgBox(0, "", "Aus der Schleife - Break !")
    ;~ _SoundPause($CurrentSound)
    Case $bn2
    MsgBox(0, "", "Aus der Schleife - Play !")
    ;~ _SoundResume($CurrentSound)
    EndSwitch
    WEnd
    #endregion ### END Playlister Loop section ###

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

    #region ### START Playlister Func section ###
    Func _File()
    MsgBox(0, "", "Aus der Funktion - Open !")
    EndFunc ;==>_File
    #endregion ### END Playlister Func section ###
    ; Ende

    [/autoit]
    Spoiler anzeigen
    [autoit]


    #include <Sound.au3>

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

    Opt("GUIOnEventMode", 1)

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

    Global $CurrentSound
    #region ### START Playlister GUI section ###
    GUICreate("Playlister", 283, 224, 634, 131)
    GUISetOnEvent(-3, "_Func")
    $lbl = GUICtrlCreateLabel("", 0, 104, 279, 17)
    $bn1 = GUICtrlCreateButton("Open", 48, 40, 75, 22)
    GUICtrlSetOnEvent(-1, "_Func")
    $bn2 = GUICtrlCreateButton("Play", 128, 152, 75, 22)
    GUICtrlSetOnEvent(-1, "_Func")
    $Pause = GUICtrlCreateButton("Break", 8, 152, 75, 22)
    GUICtrlSetOnEvent(-1, "_Func")
    $ckb = GUICtrlCreateCheckbox("Save", 160, 48, 97, 17)
    GUICtrlSetState(-1, 1)

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

    GUISetState(@SW_SHOW)
    #endregion ### END Playlister GUI section ###

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

    #region ### START Playlister Loop section ###
    While Sleep(100)
    WEnd
    #endregion ### END Playlister Loop section ###

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

    #region ### START Playlister Func section ###
    Func _Func()
    Switch @GUI_CtrlId
    Case -3
    Exit
    Case 4
    MsgBox(0, "", "Aus der Funktion - Open !")
    Case 5
    MsgBox(0, "", "Aus der Funktion - Play !")
    ;~ _SoundResume($CurrentSound)
    Case 6
    MsgBox(0, "", "Aus der Funktion - Break !")
    ;~ _SoundPause($CurrentSound)
    EndSwitch
    EndFunc ;==>_Func
    #endregion ### END Playlister Func section ###
    ; Ende

    [/autoit]