找回密码
 加入
搜索
查看: 3567|回复: 14

[AU3基础] 如何通过注册一个GUI函数 触发时间事件【结贴】

 火.. [复制链接]
发表于 2011-2-11 14:22:59 | 显示全部楼层 |阅读模式
本帖最后由 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 所以 求解 谢谢
发表于 2011-2-11 14:58:08 | 显示全部楼层
应用 OnEvent 函数方式试试,请参考《帮助》
发表于 2011-2-11 15:10:40 | 显示全部楼层
不明白你还要加_time()到循环中做什么
 楼主| 发表于 2011-2-11 15:22:50 | 显示全部楼层
回复 3# ceoguang


    要做一个GUI ListView
整点读取数据库信息
在读取的时候需要循环执行
GUICtrlCreateListViewItem 使得显示在listview里
所以正头疼这个呢
望C版 不吝赐教!
发表于 2011-2-11 15:31:01 | 显示全部楼层
本帖最后由 ceoguang 于 2011-2-11 16:25 编辑

If @SEC = "00" Then改为
If @SEC = 0  and @min = 0 Then
;这里做你要做的事就行了
endif
有什么问题?
发表于 2011-2-11 15:35:10 | 显示全部楼层
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
发表于 2011-2-11 15:57:29 | 显示全部楼层
回复 5# ceoguang

@SEC应该是数值而不是字符串吧?
发表于 2011-2-11 15:59:44 | 显示全部楼层
本帖最后由 ceoguang 于 2011-2-11 16:24 编辑
回复  ceoguang

@SEC应该是数值而不是字符串吧?
papapa314 发表于 2011-2-11 15:57


不好意思,我错了.
发表于 2011-2-11 16:02:39 | 显示全部楼层
TIMERS.AU3中_Timer_SetTimer
 楼主| 发表于 2011-2-11 16:08:15 | 显示全部楼层
回复 5# ceoguang

首先谢谢大家的关注!

If @SEC = "00" Then改为
If @SEC = "0"  and @min = "0" Then
;这里做你要做的事就行了   【有循环的话 需要等待循环结束后才能 关闭GUI 否则case $GUI_EVENT_CLOSE 不起作用啊】
endif
发表于 2011-2-11 16:24:50 | 显示全部楼层
你在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

 楼主| 发表于 2011-2-11 17:08:14 | 显示全部楼层
回复 11# ceoguang


    要做一个GUI ListView
整点读取数据库信息
在读取的时候需要循环执行
GUICtrlCreateListViewItem 使得显示在listview里
同时循环 读取的每一条记录 写到mysql里
所以正头疼这个呢

用意是这样的
发表于 2011-2-11 19:59:26 | 显示全部楼层
那是你思路有问题.
发表于 2011-2-11 20:46:59 | 显示全部楼层
学习学习
 楼主| 发表于 2011-2-13 10:56:08 | 显示全部楼层
  ok 我再想想 谢谢大家  结贴了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-21 12:34 , Processed in 0.084763 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表