我只能看懂这些了
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
;定义全局变量
Global $s = 5
;创建GUI界面
$Form1 = GUICreate("Form1", 297, 122, 192, 124)
;创建按钮
$Button1 = GUICtrlCreateButton("倒计时(" & $s & "秒)", 80, 72, 129, 33)
;显现界面
GUISetState(@SW_SHOW)
;定义回调函数
$Timer = DllCallbackRegister("_daojishi", "int", "hwnd;uint;uint;dword")
;调用user32.dll里的SetTimer函数,1000毫秒回调到自定义函数
$TimerDLL = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 1000, "ptr", DllCallbackGetPtr($Timer))
;生成无限循环
While 1
; 定义变量值为捕获窗口消息
$nMsg = GUIGetMsg()
;创建条件$nMsg语句
Switch $nMsg
;如果满足$GUI_EVENT_CLOSE(点击关闭按钮), $Button1(点击按钮)
Case $GUI_EVENT_CLOSE, $Button1
;执行KillTimer函数
DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "uint", $TimerDLL[0])
;退出
Exit
; 条件句结束语
EndSwitch
;while循环句结束
WEnd
;自定义函数
Func _daojishi($hWnd, $uiMsg, $Form1_idEvent, $dwTime)
;如果 $s<1 那么
If $s < 1 Then
;刷新按钮文本为'退出'
GUICtrlSetData($Button1, "退出")
;退出
Exit
;结束if语句
EndIf
;变量$s在经过1000毫秒后执行自身减1,既$s=$s-1
$s -= 1
;刷新按钮文本为 "倒计时"加自身减1后的值
GUICtrlSetData($Button1, "倒计时(" & $s & "秒)")
;自定义函数结束语
EndFunc ;==>_daojishi
|