创建一个GUI,在一定时间内退出,不影响关闭程序
如题,比如创建个gui,30秒后关闭,不能多线程or进程,也不能用sleep(除非必要,但不能影响$GUI_EVENT_CLOSE或其它GUIMsg),要如何写呢?算是考考新人 回复 1# kn007 GUICreate('30s Gui')
GUISetState()
$ts = TimerInit()
While TimerDiff($ts) / 1000 <= 30
Switch GUIGetMsg()
Case -3
Exit
EndSwitch
WEnd GUICreate('30s Gui')
GUISetState()
AdlibRegister("is30",3000)
$n=0
While 1
Switch GUIGetMsg()
Case -3
Exit
EndSwitch
WEnd
Func is30()
If $n=10 Then Exit
$n+=1
EndFunc
#include <GUIConstantsEx.au3>
GUICreate('test')
GUISetState()
AdlibRegister("_exit", 30000)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func _exit ()
Exit
EndFunc
#include <GUIConstantsEx.au3>
#include <Date.au3>
GUICreate('test')
GUISetState()
$Str = _NowCalc()
While 1
If _DateDiff('s', $Str, _NowCalc()) = 30 Then Exit
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd 呵呵,方法不少。 这么多的方法,学习了。 本帖最后由 gapkiller 于 2010-1-14 15:56 编辑
我就要用sleep,怎么滴...
Opt("GUIOnEventMode", 1)
GUICreate('30s Gui')
GUISetOnEvent(-3, "Quit")
GUISetState()
sleep(30000)
Func Quit()
Exit
EndFunc
; 我顶2楼
把那个msgbox中的settimer api移植一下 真的是各有各招 我的想法是把那个30秒,分成1500个20毫秒,20毫秒一个循环,1500个循环之后就退出gui,所以不会影响其他的操作啦。。。除非你能手动在20毫秒之内进行一次以上的键盘鼠标操作。。。 除非你能手动在20毫秒之内进行一次以上的键盘鼠标操作
很容易吧...
再说,程序运行也需要时间滴...不准确
页:
[1]