AUTOT - 停止循环

问题描述 投票:0回答:1

我有代码一迷你应用程序。 我想询问是否退出一段时间。

但毕竟是在不工作的时候。

我分享所有代码:

Global $test


$choice = GUICreate("Custom MsgBox", 225, 80)
GUICtrlCreateLabel("Please select a button.", 10, 10)
Local $idYess = GUICtrlCreateButton("YES", 10, 50, 65, 25)
Local $idNoo = GUICtrlCreateButton("NON", 80, 50, 65, 25)
Local $idExitt = GUICtrlCreateButton("EXIT", 150, 50, 65, 25)
GUISetState(@SW_SHOW, $choice)

Local $iMsgBoxAnswer = 1, $bLoop = True

While $bLoop
    Switch GUIGetMsg()
        Case $idYess
            ConsoleWrite("$idYess=" & $idYess & @CRLF)

        Case $idNoo
            ConsoleWrite("$idNoo=" & $idNoo & @CRLF)

    EndSwitch
    
    

    If $iMsgBoxAnswer = 1 Then ContinueLoop
        

    $iMsgBoxAnswer = MsgBox(4100, "MsgBox", "Are you sure you want to close the program?", 3)
    Select
        Case $iMsgBoxAnswer = 6 ;Yes
            ConsoleWrite("- bye bye" & @CRLF)
            $bLoop = False

    EndSelect

WEnd 
      
Global $num = 1    
    
While 1
                                            
  Switch $num

    Case "1"
    MsgBox(0, '', 'Number 1')
    ExitLoop 
    
  EndSwitch
  
Wend

为什么我的第二个不工作?

以及为什么它在第一个循环上单击退出后才起作用。

你能帮我解决我的问题吗?

谢谢

automation autohotkey autoit
1个回答
0
投票

这是你想要的吗?

#include <MsgBoxConstants.au3>


$choice = GUICreate("Custom MsgBox", 225, 80)
GUICtrlCreateLabel("Please select a button.", 10, 10)
Local $idYess = GUICtrlCreateButton("YES", 10, 50, 65, 25)
Local $idNoo = GUICtrlCreateButton("NON", 80, 50, 65, 25)
Local $idExitt = GUICtrlCreateButton("EXIT", 150, 50, 65, 25)
GUISetState(@SW_SHOW, $choice)

Local $iMsgBoxAnswer = 1

While 1
    Switch GUIGetMsg()
        Case $idYess
            ConsoleWrite("$idYess=" & $idYess & @CRLF)
            _reallyExit()
        Case $idNoo
            ConsoleWrite("$idNoo=" & $idNoo & @CRLF)

        Case $idExitt
            ConsoleWrite("$idExitt=" & $idExitt & @CRLF)
            _reallyExit()
    EndSwitch
WEnd

Func _reallyExit()
    $iMsgBoxAnswer = MsgBox(4100, "MsgBox", "Are you sure you want to close the program?", 3)
    If $iMsgBoxAnswer = $IDYES Then
        ConsoleWrite("- bye bye" & @CRLF)
        Exit
    EndIf
EndFunc   ;==>_reallyExit
© www.soinside.com 2019 - 2024. All rights reserved.