Sicherheitsabfrage beim Beenden

  • Hallo zusammen. ich hab hier ein kleines aber sehr simples problem!

    Beim drücken auf X der GUI soll eine MsgBox(4) erscheinen, die beim drücken auf "Ja" das gesammte script (also GUI+MsgBox) schließt und beim Drücken auf "Nein" nur die MsgBox schliesst.
    Das Problem liegt darin, das er mit zb. Exit das script nicht beendet, wenn man auf den "Ja" button in der MsgBox(4) klickt... kp warum
    Code:

    GUICreate ("Programm", 600, 500)
    GUISetState (@SW_Show)
    AutoItSetOption ("GUICloseOnEsc", 0)

    While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
    MsgBox (4, "sicherheitsabfrage?", "frage")
    EndSelect
    Wend

    $beenden = MsgBox (4, "sicherheitsabfrage?", "frage")
    If $beenden = ;HIER IST MEIN PROBLEM
    ElseIf $beenden = 7 Then
    WinClose ("sicherheitsabfrage?", "frage")
    Endif

    Einmal editiert, zuletzt von MaxSony (2. Februar 2009 um 22:07)

  • [autoit]


    #include <GUIConstantsEx.au3>
    GUICreate("Programm", 600, 500)
    GUISetState(@SW_SHOW)
    AutoItSetOption("GUICloseOnEsc", 0)

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

    While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
    $beenden = MsgBox(4, "sicherheitsabfrage?", "frage")
    If $beenden = 6 Then Exit
    EndSelect
    WEnd

    [/autoit]


    Padmak

  • Oder so:

    [autoit]

    #include <GuiConstants.au3>

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

    GUICreate("Programm", 600, 500)
    GUISetState(@SW_SHOW)
    AutoItSetOption("GUICloseOnEsc", 0)

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

    While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
    $iMsgBoxAnswer = MsgBox(36, "sicherheitsabfrage?", "Frage")
    Select
    Case $iMsgBoxAnswer = 6 ;Yes
    Exit
    Case $iMsgBoxAnswer = 7 ;No
    ;Wenn nichts passieren soll freilassen
    EndSelect
    EndSelect
    WEnd

    [/autoit]
  • warum machst dus per select?
    ist mir klar dasses normal schneller ist aber bei 2 statements? :D

    Padmak

    • Offizieller Beitrag

    Ja, Switch ist schneller :D

  • Select entsptricht Switch True ;)

    Spoiler anzeigen
    [autoit]

    $a = Number(InputBox("Zahl a","Zahl a",4))
    $b = Number(InputBox("Zahl b","Zahl b",4))

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

    Switch True
    Case $a < $b
    MsgBox(0, '', "<")
    Case $a = $b
    MsgBox(0, '', "=")
    Case $a > $b
    MsgBox(0, '', ">")
    EndSwitch

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

    Select
    Case $a < $b
    MsgBox(0, '', "<")
    Case $a = $b
    MsgBox(0, '', "=")
    Case $a > $b
    MsgBox(0, '', ">")
    EndSelect

    [/autoit]
  • Hm if ist bei mir am schnellsten oO

    [autoit]


    $a = Number(InputBox("Zahl a", "Zahl a", 4))
    $b = Number(InputBox("Zahl b", "Zahl b", 4))
    $timer1 = TimerInit()
    Switch True
    Case $a < $b
    ;~ MsgBox(0, '', "<")
    Case $a = $b
    ;~ MsgBox(0, '', "=")
    Case $a > $b
    ;~ MsgBox(0, '', ">")
    EndSwitch
    $timerende1 = TimerDiff($timer1)

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

    $timer2 = TimerInit()
    Select
    Case $a < $b
    ;~ MsgBox(0, '', "<")
    Case $a = $b
    ;~ MsgBox(0, '', "=")
    Case $a > $b
    ;~ MsgBox(0, '', ">")
    EndSelect
    $timerende2 = TimerDiff($timer2)

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

    $timer3 = TimerInit()
    If $a < $b Then
    ;~ MsgBox(0, '', "<")
    ElseIf $a = $b Then
    ;~ MsgBox(0, '', "=")
    ElseIf $a > $b Then
    ;~ MsgBox(0, '', ">")
    EndIf
    $timerende3 = TimerDiff($timer3)
    MsgBox(0, "", "Von Switch benötigte Zeit " & $timerende1 & @CRLF & _
    "Von Select benötigte Zeit " & $timerende2 & @CRLF & _
    "Von If benötigte Zeit " & $timerende3)

    [/autoit]
  • Das liegt daran, das bei den älteren Versionen von Autoit es nur guiconstans.au3 gab und guiconstantsex.au3 erst in der 3er oder so Version gibt und da mehr constanten gibt, man hat aber guiconstants.au3 gelassen bzw. die erweiterungen die es in guiconstansex.au3 gibt mit eingebunden, damit Skripte noch funktionieren die mit älteren Version von autoIT geschrieben sind ohne sie zu ändern.

    Das muss man jetzt nicht verstehen, was ich da geschrieben hab :thumbup:

    mfg