GUI während For-Schleife schließen

  • Hi,

    ich habe folgendes Script:

    Spoiler anzeigen
    [autoit]

    #include <ts3.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiButton.au3>

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

    #region ### START Koda GUI section ### Form=
    $loginform = GUICreate("Login", 272, 149, 192, 124)
    $serverinput = GUICtrlCreateInput("", 80, 8, 177, 26)
    GUICtrlSetFont(-1, 12, 400, 0, "Arial")
    $serverlable = GUICtrlCreateLabel("Server:", 8, 8, 54, 22)
    GUICtrlSetFont(-1, 12, 400, 0, "Arial")
    $userinput = GUICtrlCreateInput("", 80, 43, 177, 26)
    GUICtrlSetFont(-1, 12, 400, 0, "Arial")
    $userlable = GUICtrlCreateLabel("User:", 8, 43, 41, 22)
    GUICtrlSetFont(-1, 12, 400, 0, "Arial")
    $passwortinput = GUICtrlCreateInput("", 82, 77, 177, 26)
    GUICtrlSetFont(-1, 12, 400, 0, "Arial")
    $passwortlable = GUICtrlCreateLabel("Passwort:", 10, 77, 73, 22)
    GUICtrlSetFont(-1, 12, 400, 0, "Arial")
    $loginbutton = GUICtrlCreateButton("Login", 80, 112, 75, 25)
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $loginbutton
    _TS3connect(GUICtrlRead($serverinput))
    $wert = _TS3login(GUICtrlRead($userinput), GUICtrlRead($passwortinput))
    If $wert > 1 Then
    _GUICtrlButton_Enable($loginbutton, False)
    For $i = $wert To 0 Step -1
    GUICtrlSetData($loginbutton, "Ban: " & $i)
    Sleep(1000)
    Next
    GUICtrlSetData($loginbutton, "Login")
    _GUICtrlButton_Enable($loginbutton, True)
    EndIf
    EndSwitch
    WEnd

    [/autoit]

    Die ts3.au3 ist in meiner Sig, ist aber für mein Problem nicht nötig. Wie man sieht wird nach einem klick auf den Loginbutton geprüft ob der Wert in $wert >1 ist. Wenn ja wird wird der Button deaktivier und eine forschleife ausgeführt bist $wert auf 0 ist. Soweit funktioniert das auch.
    Mein Problem ist nun aber, dass während die For-Schleife läuft man die GUI nicht schließen kann, weil ja nicht auf $GUI_EVENT_CLOSE geprüft wird. Eine Umstellung auf onEvent brauchte genausowenig einen Erfolg wie auch der Einsatz von adlib.

    Hat jemand eine Idee?

    Andy hat mir ein Schnitzel gebacken aber da war ein Raupi drauf und bevor Oscar das Bugfixen konnte kam Alina und gab mir ein AspirinJunkie.

    Einmal editiert, zuletzt von chip (30. März 2011 um 23:13)

  • hmmm ... versuch das mal, vielleicht geht das ...

    Spoiler anzeigen
    [autoit]

    For $i = $wert To 0 Step -1
    $nMsg = GUIGetMsg()
    If $nMsg = $GUI_EVENT_CLOSE Then Exit
    GUICtrlSetData($loginbutton, "Ban: " & $i)
    Sleep(1000)
    Next

    [/autoit]
    • Offizieller Beitrag

    chip, so sollte es klappen:

    Spoiler anzeigen
    [autoit]

    #include <GuiButton.au3>
    #include <GUIConstantsEx.au3>
    #include <MenuConstants.au3>
    #include <WindowsConstants.au3>
    #include <ts3.au3>

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

    #region ### START Koda GUI section ### Form=
    $loginform = GUICreate("Login", 272, 149, 192, 124)
    $serverinput = GUICtrlCreateInput("", 80, 8, 177, 26)
    GUICtrlSetFont(-1, 12, 400, 0, "Arial")
    $serverlable = GUICtrlCreateLabel("Server:", 8, 8, 54, 22)
    GUICtrlSetFont(-1, 12, 400, 0, "Arial")
    $userinput = GUICtrlCreateInput("", 80, 43, 177, 26)
    GUICtrlSetFont(-1, 12, 400, 0, "Arial")
    $userlable = GUICtrlCreateLabel("User:", 8, 43, 41, 22)
    GUICtrlSetFont(-1, 12, 400, 0, "Arial")
    $passwortinput = GUICtrlCreateInput("", 82, 77, 177, 26)
    GUICtrlSetFont(-1, 12, 400, 0, "Arial")
    $passwortlable = GUICtrlCreateLabel("Passwort:", 10, 77, 73, 22)
    GUICtrlSetFont(-1, 12, 400, 0, "Arial")
    $loginbutton = GUICtrlCreateButton("Login", 80, 112, 75, 25)
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###
    GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND")
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $loginbutton
    _TS3connect(GUICtrlRead($serverinput))
    $wert = _TS3login(GUICtrlRead($userinput), GUICtrlRead($passwortinput))
    If $wert > 1 Then
    _GUICtrlButton_Enable($loginbutton, False)
    For $i = $wert To 0 Step -1
    GUICtrlSetData($loginbutton, "Ban: " & $i)
    Sleep(1000)
    if GUIGetMsg() = $GUI_EVENT_CLOSE then Exit
    Next
    GUICtrlSetData($loginbutton, "Login")
    _GUICtrlButton_Enable($loginbutton, True)
    EndIf
    EndSwitch
    WEnd

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

    Func WM_SYSCOMMAND($hGUI, $iMsg, $wParam = 0, $lParam = 0)
    If $wParam = $SC_CLOSE Then Exit
    Return $GUI_RUNDEFMSG
    EndFunc

    [/autoit]