kn007 发表于 2010-1-12 22:32:18

创建一个GUI,在一定时间内退出,不影响关闭程序

如题,比如创建个gui,30秒后关闭,不能多线程or进程,也不能用sleep(除非必要,但不能影响$GUI_EVENT_CLOSE或其它GUIMsg),要如何写呢?

算是考考新人

afan 发表于 2010-1-12 22:41:19

回复 1# kn007 GUICreate('30s Gui')
GUISetState()
$ts = TimerInit()
While TimerDiff($ts) / 1000 <= 30
        Switch GUIGetMsg()
                Case -3
                        Exit
        EndSwitch
WEnd

顽固不化 发表于 2010-1-12 22:51:56

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
       

C.L 发表于 2010-1-12 22:57:45


#include <GUIConstantsEx.au3>
GUICreate('test')
GUISetState()
AdlibRegister("_exit", 30000)
While 1
        Switch GUIGetMsg()
                Case $GUI_EVENT_CLOSE
                        Exit
        EndSwitch
WEnd

Func _exit ()
        Exit
EndFunc

顽固不化 发表于 2010-1-12 23:09:49

#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

范统.贾 发表于 2010-1-13 07:19:48

呵呵,方法不少。

hh_wzj 发表于 2010-1-14 00:04:09

这么多的方法,学习了。

gapkiller 发表于 2010-1-14 15:55:11

本帖最后由 gapkiller 于 2010-1-14 15:56 编辑

我就要用sleep,怎么滴...
Opt("GUIOnEventMode", 1)
GUICreate('30s Gui')
GUISetOnEvent(-3, "Quit")
GUISetState()
sleep(30000)

Func Quit()
    Exit
EndFunc
; 我顶2楼

netegg 发表于 2010-1-14 16:04:42

把那个msgbox中的settimer api移植一下

ndyndy 发表于 2010-1-15 10:54:46

真的是各有各招

sanmoking 发表于 2010-1-15 11:25:03

我的想法是把那个30秒,分成1500个20毫秒,20毫秒一个循环,1500个循环之后就退出gui,所以不会影响其他的操作啦。。。除非你能手动在20毫秒之内进行一次以上的键盘鼠标操作。。。

gapkiller 发表于 2010-1-15 11:28:24

除非你能手动在20毫秒之内进行一次以上的键盘鼠标操作

很容易吧...

再说,程序运行也需要时间滴...不准确
页: [1]
查看完整版本: 创建一个GUI,在一定时间内退出,不影响关闭程序