HotKeySet("s","Myfunc") ;注册热键 小写字母s
Global $Count=0,$Start=TimerInit() ;定义次数变量 时间控制变量并初始化
While 1 ;创建死循环。
Sleep(1000) ;延迟1秒。 因为有了热键,这个消息循环基本上没什么用,延迟时间长点防CPU使用率高
ConsoleWrite("开始了"&Int(TimerDiff($Start)/1000)&"秒"&@CRLF) ;输出程序运行了几秒 10秒一轮
WEnd
Func Myfunc()
$Count+=1 ;首先将次数控制变量加1. 因为初始化的是0,而我们要的是3次。0到3是4次。
If TimerDiff($Start)<10000 And $Count>3 Then Return ;若时间小于10秒且次数超过3次 则返回
If $Count<=3 Then ConsoleWrite($Count) ;次数小于3,输出当前次数
If TimerDiff($Start)>10000 Then ;大于10秒, 初始化
$Start=TimerInit()
$Count=0
EndIf
EndFunc