找回密码
 加入
搜索
查看: 1378|回复: 3

[AU3基础] [已解决]请教如何终止程序内某个Func参数

[复制链接]
发表于 2017-2-24 15:52:28 | 显示全部楼层 |阅读模式
本帖最后由 zhaoceshi 于 2017-2-27 10:13 编辑

如题,代码如下。
怎么可以写成按下F3就会停止func ZK 这个参数而不退出程序呢。
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

HotKeySet("{esc}", "Terminate")
HotKeySet("{F2}", "ZK")


While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd

Func ZK()
        For $i = 1 To 999
                MsgBox(0,0,$i,1)
        Next
EndFunc


Func Terminate()
        Exit
EndFunc   ;==>Terminate
发表于 2017-2-24 16:10:30 | 显示全部楼层
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$Btn_start = GUICtrlCreateButton("开始循环", 50, 50, 70, 30)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

HotKeySet("{esc}", "Terminate")
HotKeySet("{F2}", "_ChangeTag")
Global $sTag = False

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Btn_start
                        GUICtrlSetState($Btn_start, 128)
                        ZK()
                        GUICtrlSetState($Btn_start, 64)
        EndSwitch
WEnd

Func ZK()
        For $i = 1 To 999
                If $sTag = True Then 
                        $sTag = False
                        Return 
                EndIf
                MsgBox(0, 0, $i, 1,$Form1)
        Next
EndFunc   ;==>ZK

Func _ChangeTag()
        $sTag = Not $sTag
EndFunc

Func Terminate()
        Exit
EndFunc   ;==>Terminate
 楼主| 发表于 2017-2-24 16:12:46 | 显示全部楼层
感谢大神
发表于 2017-2-24 16:28:14 | 显示全部楼层
我只会在 ZK() 里面加一个 flag
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-19 09:20 , Processed in 0.074124 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表