本帖最后由 shqf 于 2013-5-23 11:02 编辑
SLEEP是延迟时间,就是暂停脚本运行一定时间,用此来获得倒计秒数,在延迟时段内程序是没法响应的。
可用timer函数或_DateDiff等。如下timer函数解决:#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
GUICreate("自动输出", 297, 150, 192, 124, $WS_DLGFRAME, $WS_EX_TOPMOST)
GUICtrlCreateLabel("20秒后输出,如正在使用,请取消", 20, 20)
$Button1 = GUICtrlCreateButton("倒计时(20秒)运行", 20, 72, 120, 30)
$Button2 = GUICtrlCreateButton("退出", 150, 72, 70, 30)
GUISetState(@SW_SHOW)
Local $hTimer = TimerInit()
Local $i=20
While $i<>0
$msg = GUIGetMsg()
If $msg = $Button2 Then Exit
If $msg = $Button1 Then ExitLoop
Local $iDiff = TimerDiff($hTimer)
$i = 20 - Int($iDiff / 1000)
If GUICtrlRead($Button1) <> "倒计时(" & $i & "秒)" Then
GUICtrlSetData($Button1, "倒计时(" & $i & "秒)")
EndIf
WEnd
If ProcessExists("QCSoft.exe") Then WinActivate("[CLASS:QCSoft]")
|