本帖最后由 ceoguang 于 2010-11-21 00:53 编辑
方法2:
#include <WinAPI.au3>
Global $Struct = DllStructCreate($tagPoint)
Global $WindowsWidth = _WinAPI_GetSystemMetrics(0)
Global $WindowsHeight = _WinAPI_GetSystemMetrics(1)
$Form1 = GUICreate("倒计时", 350, 172, 193, 125)
$Label1 = GUICtrlCreateLabel("即将开始.....", 56, 32, 232, 28)
GUICtrlSetFont(-1, 18, 400, 0, "楷体_GB2312")
$Progress1 = GUICtrlCreateProgress(8, 88, 333, 17)
$Button1 = GUICtrlCreateButton("确定(&Y)", 53, 128, 73, 25, 0)
$Button2 = GUICtrlCreateButton("退出(&X)", 210, 128, 73, 25, 0)
GUISetState(@SW_SHOW)
Global $time = 30
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3, $Button2
Exit
Case $Button1
ExitLoop
EndSwitch
If IsFullWindow() Then ;全屏
AdlibRegister("_timer", 1000) ;调试时将时间设置更短效果更明显
EndIf
WEnd
Func _timer()
$time -= 1
GUICtrlSetData($Label1, $time & "秒后将进入!")
GUICtrlSetData($Progress1, (30 - $time) / 0.3)
Select
Case $time <= 0
;GUICtrlSetData($Progress1, 0) 非调试时可去除
$time = 30
Run("执行程序")
Return AdlibUnRegister("_timer")
Case Not (IsFullWindow())
GUICtrlSetData($Label1, "非全屏!")
;GUICtrlSetData($Progress1, 0)
$time = 30
AdlibUnRegister("_timer")
EndSelect
EndFunc ;==>_timer
Func IsFullWindow() ;检测当前窗口是否全屏,是:返回1,否则返回0
Pos()
$hwnd = _WinAPI_WindowFromPoint($Struct)
If $hwnd = _WinAPI_GetDesktopWindow() Then Return 0 ;不检测资源管理器
$tRect = _WinAPI_GetWindowRect($hwnd)
$iLeft = DllStructGetData($tRect, "Left")
$iTop = DllStructGetData($tRect, "Top")
$iRight = DllStructGetData($tRect, "Right")
$iBottom = DllStructGetData($tRect, "Bottom")
If $WindowsWidth <= $iRight - $iLeft And $WindowsHeight <= $iBottom - $iTop Then Return 1
Return 0
EndFunc ;==>IsFullWindow
Func Pos()
DllStructSetData($Struct, "x", MouseGetPos(0))
DllStructSetData($Struct, "y", MouseGetPos(1))
EndFunc ;==>Pos
|