如何通过注册一个GUI函数 触发时间事件【结贴】
本帖最后由 haodd 于 2011-2-13 10:56 编辑#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
Dim $i = 0
$Form1 = GUICreate("Form1", 275, 93, 192, 114)
$Label1 = GUICtrlCreateLabel("整分字体变红", 48, 32, 164, 17)
;~ GUICtrlSetColor(-1, 0xff0000)
AdlibRegister("_time",1000) ;======> 现在时刻
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
_time()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func _time()
If @SEC = "00" Then
GUICtrlSetColor(-1, 0xff0000)
Else
While $i < 21
$i += 1
Sleep(1000)
WEnd
GUICtrlSetColor(-1, 0x000000)
EndIf
EndFunc如果这样做的话 内部有不能执行完的循环将不能正常关闭GUI 所以 求解 谢谢 应用 OnEvent 函数方式试试,请参考《帮助》 不明白你还要加_time()到循环中做什么 回复 3# ceoguang
要做一个GUI ListView
整点读取数据库信息
在读取的时候需要循环执行
GUICtrlCreateListViewItem 使得显示在listview里
所以正头疼这个呢
望C版 不吝赐教! 本帖最后由 ceoguang 于 2011-2-11 16:25 编辑
If @SEC = "00" Then改为
If @SEC = 0and @min = 0 Then
;这里做你要做的事就行了
endif
有什么问题? Opt("GUIOnEventMode", 1)
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
Dim $i = 0
$Form1 = GUICreate("Form1", 275, 93, 192, 114)
$Label1 = GUICtrlCreateLabel("整分字体变红", 48, 32, 164, 17)
;~ GUICtrlSetColor(-1, 0xff0000)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
AdlibRegister("_time",10) ;======> 现在时刻
GUISetOnEvent($GUI_EVENT_CLOSE,"close")
While 1
WEnd
Func _time()
If @SEC = "00" Then
GUICtrlSetColor(-1, 0xff0000)
Else
While $i < 21
$i += 1
Sleep(1000)
WEnd
GUICtrlSetColor(-1, 0x000000)
EndIf
EndFunc
Func close()
Exit
EndFunc 回复 5# ceoguang
@SEC应该是数值而不是字符串吧? 本帖最后由 ceoguang 于 2011-2-11 16:24 编辑
回复ceoguang
@SEC应该是数值而不是字符串吧?
papapa314 发表于 2011-2-11 15:57 http://www.autoitx.com/images/common/back.gif
不好意思,我错了. TIMERS.AU3中_Timer_SetTimer 回复 5# ceoguang
首先谢谢大家的关注!
If @SEC = "00" Then改为
If @SEC = "0"and @min = "0" Then
;这里做你要做的事就行了 【有循环的话 需要等待循环结束后才能 关闭GUI 否则case $GUI_EVENT_CLOSE 不起作用啊】
endif 你在adlib内循环做什么?
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 275, 93, 192, 114)
$Label1 = GUICtrlCreateLabel("整分字体变红", 48, 32, 164, 17)
AdlibRegister("_time", 1000) ;======> 现在时刻
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $IsSetColor = False
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func _time()
If @MIN = 0 And @SEC < 5 Then ;正点5秒内字体变红
GUICtrlSetColor($Label1, 0xff0000)
$IsSetColor = Not $IsSetColor
Else
If $IsSetColor Then
GUICtrlSetColor($Label1, 0x000000)
$IsSetColor = Not $IsSetColor
EndIf
EndIf
EndFunc ;==>_time
回复 11# ceoguang
要做一个GUI ListView
整点读取数据库信息
在读取的时候需要循环执行
GUICtrlCreateListViewItem 使得显示在listview里
同时循环 读取的每一条记录 写到mysql里
所以正头疼这个呢
用意是这样的 那是你思路有问题. 学习学习{:face (88):} {:face (396):}ok 我再想想 谢谢大家结贴了
页:
[1]