zouyifeng 发表于 2009-4-13 17:25:12

如何让程序暂停

比如循环中用户按一个键让程序暂停运行,再按一个键又恢复运行,请问如何实现

pusofalse 发表于 2009-4-13 17:48:29

Global $iFlag

HotKeySet("{f4}", "_Suspend")
HotKeySet("{f5}", "_Resume")
HotKeySet("{f6}", "_Exit")

While 1
        Sleep(1000)
        Msgbox(0, '', "Test")
WEnd

Func _Exit()
        Exit
EndFunc        ;==>_Exit()

Func _Suspend()
        Do
                Sleep(20)
        Until        $iFlag
        $iFlag = 0
EndFunc        ;==>_Suspend()

Func _Resume()
        $iFlag = 1
EndFunc        ;==>_Resume()

zjimmy 发表于 2009-4-13 17:51:31

可以通过设置热键的方式解决

tongdu.simon 发表于 2009-4-27 11:12:31


Global $Paused=False        ;For TogglePuase()

$shtcut="{PAUSE}"
HotKeySet($shtcut,"TogglePause")

Func TogglePause()
   $Paused = NOT $Paused
      While $Paused
            Sleep(100)
      WEnd
EndFunc
页: [1]
查看完整版本: 如何让程序暂停