找回密码
 加入
搜索
查看: 3083|回复: 8

[已解决]GUI上静态显示时间

[复制链接]
发表于 2009-3-10 13:21:11 | 显示全部楼层 |阅读模式
相关代码如下:
Global $timer = TimerInit()
Global $time, $Hour, $Mins, $Secs,$Time
Local $mytime
;$an[5] = "星期"&@WDAY&" "&@HOUR&":"&@MIN&":"&@SEC
$mytime = "" & @HOUR & ":" & @MIN & ":" & @SEC
_TicksToTime(Int(TimerDiff($timer)), $Hour, $Mins, $Secs)
$Label_time =GUICtrlCreateLabel("", 185, 262, 110, 20)
GUICtrlSetData($Label_time, $mytime)
下面的时间一直显示是程序启动时间,无法随系统时间变化而变化,请指点那儿写错了
把代码加入While 1-wend后,时间问题正常了,但在点击了主窗口后出现子窗口,一直关不了,关了又出现一个

[ 本帖最后由 jycel 于 2009-3-10 16:16 编辑 ]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2009-3-10 13:44:39 | 显示全部楼层
因为你没有更新控件的状态

时间当然是启动时的时间了(也就是只是更新了一回状态)

你可以把上面一段写到 While 1 sleep() Wend 中

或者用adlibenable("Func")
 楼主| 发表于 2009-3-10 13:53:59 | 显示全部楼层
放到While 1 sleep() Wend 中OK了,多谢指点!又学着了!
更简单一点
While 1

$Label_time= GUICtrlCreateLabel("Label2", 185, 262, 110, 20)
GUISetState(@SW_SHOW)
GUICtrlSetData($Label_time,@HOUR&':'&@MIN&':'&@SEC)

Sleep(1000)

WEnd

[ 本帖最后由 jycel 于 2009-3-10 14:05 编辑 ]
发表于 2009-3-10 14:41:53 | 显示全部楼层
多看看帮助文档就行了
 楼主| 发表于 2009-3-10 15:40:24 | 显示全部楼层
全部代码如下,修正时间后,子窗口不停弹出,关了又弹出来,但不在While和wend中加时间代码又不会出现
adlibenable("Func")函数不知道怎么使用,一直出错

#include <GUIConstants.au3>
#include<process.au3>
#include <ButtonConstants.au3>
#include <GuiStatusBar.au3>
#include <IE.au3>
#Include <Date.au3>

Opt("GUIOneventMode",1)
Dim $Button[40],$lr1,$CD,$an[10]

$WinMain  = GUICreate("【飛翔網絡】程序正在开发中", 440, 300)            ;创建主窗口
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")             ;注册窗口关闭事件到函数_Exit
;GUICtrlCreateButton ( "文本", 左侧, 上方 [, 宽度 [, 高度 [, 样式 [, 扩展样式]]]] ) 
GUISetBkColor(0xf66ccc)
$an[0]  = GUICtrlCreateGroup("快速通道",0,5,67,280)
$Button[0]  = GUICtrlCreateButton("在线影院", 3, 20, 60, 32);显示子窗口 1
$Button[1]  = GUICtrlCreateButton("下载中心", 3, 54, 60, 32);显示子窗口 2
$Button[2]  = GUICtrlCreateButton("留言中心", 3, 88, 60, 32);显示子窗口 3
$Button[3]  = GUICtrlCreateButton("按钮", 3, 122, 60, 32);显示子窗口 4
$Button[4]  = GUICtrlCreateButton("网络测试", 3, 156, 60, 32);显示子窗口 5
$Button[5]  = GUICtrlCreateButton("路由查询", 3, 190, 60, 32);显示子窗口 6
$Button[6] = GUICtrlCreateButton("系统清理", 3, 224, 60, 32)
$Button[7]  = GUICtrlCreateButton("AU3论坛", 3, 258, 60, 22);显示子窗口 8
$Button[24] = GUICtrlCreateButton("全部", 83, 50, 45, 20)
$Button[25] = GUICtrlCreateButton("网页", 143, 50, 45, 20)
$Button[26] = GUICtrlCreateButton("影视", 203, 50, 45, 20)
$Button[27] = GUICtrlCreateButton("在线", 263, 50, 45, 20)
$Button[28] = GUICtrlCreateButton("音乐", 323, 50, 45, 20)
$Button[34] = GUICtrlCreateButton("歌词", 383, 50, 45, 20)
$Button[29] = GUICtrlCreateButton("图片", 83, 72, 45, 20)
$Button[30] = GUICtrlCreateButton("书籍", 143, 72, 45, 20)
$Button[31] = GUICtrlCreateButton("软件", 203, 72, 45, 20)
$Button[32] = GUICtrlCreateButton("游戏", 263, 72, 45, 20)
$Button[33] = GUICtrlCreateButton("全集", 323, 72, 45, 20)
$Button[35] = GUICtrlCreateButton("知道", 383, 72, 45, 20)
$Button[36] = GUICtrlCreateButton("新闻", 323, 23, 45, 20)
$Button[37] = GUICtrlCreateButton("贴吧", 383, 23, 45, 20)
GuiCtrlCreatePic("\\192.168.0.136\update$\au3\logo.jpg",68,100, 370,157)
$an[1]= GUICtrlCreateGroup("搜索工具",70,5,370,95)
$an[2]= GUICtrlCreateInput("", 80, 20, 230, 25)
;$an[3] = GUICtrlCreateGroup("说明", 360, 13, 76, 78)
;$an[4]= GUICtrlCreateLabel("请输入查找内容后直接点击下面相关类型即可", 370, 33, 60, 50);使用说明
GuiCtrlCreateDate("", 68, 258, 110, 20)

$StatusBar1 = _GUICtrlStatusBar_Create($WinMain)
Dim $StatusBar1_PartsWidth[3] = [100, 220, 400]
Dim $S0 = "    欢迎光临   ", $S1 = "飛翔網絡 By Jycel", $S2=" E-mail:jycel@qq.com"
_GUICtrlStatusBar_SetParts($StatusBar1, $StatusBar1_PartsWidth)
_GUICtrlStatusBar_SetText($StatusBar1, $S2, 2)
_GUICtrlStatusBar_SetText($StatusBar1, $S1, 1)
_GUICtrlStatusBar_SetText($StatusBar1, $S0, 0)
_GUICtrlStatusBar_SetMinHeight($StatusBar1, 15)
$WinSub1  = GUICreate("在线影院", 220, 60)                ;创建子窗口1
GUISetOnEvent($GUI_EVENT_CLOSE, "GUICtrlMsg")           ;注册窗口关闭事件到函数GUICtrlMsg
$Button[8] = GUICtrlCreateButton("网吧影院", 0, 0, 100, 50,$BS_DEFPUSHBUTTON)
$Button[9]= GUICtrlCreateButton("互动网盟", 110, 0, 100, 50,$BS_DEFPUSHBUTTON);创建子窗口中按钮二

$WinSub2  = GUICreate("下载中心", 220, 60)                ;创建子窗口2
GUISetOnEvent($GUI_EVENT_CLOSE, "GUICtrlMsg")           ;注册窗口关闭事件到函数GUICtrlMsg
$Button[10]= GUICtrlCreateButton("下载地址1", 0, 0, 100, 50,$BS_DEFPUSHBUTTON)
$Button[11]= GUICtrlCreateButton("下载地址2", 110, 0, 100, 50,$BS_DEFPUSHBUTTON);创建子窗口中按钮二

$WinSub3  = GUICreate("网吧论坛", 220, 60)                ;创建子窗口2
GUISetOnEvent($GUI_EVENT_CLOSE, "GUICtrlMsg")           ;注册窗口关闭事件到函数GUICtrlMsg
$Button[12] = GUICtrlCreateButton("登陆", 0, 0, 100, 50,$BS_DEFPUSHBUTTON)
$Button[13] = GUICtrlCreateButton("返回", 110, 0, 100, 50,$BS_DEFPUSHBUTTON);创建子窗口中按钮二

$WinSub4  = GUICreate("在线冲值", 220, 60)                ;创建子窗口2
GUISetOnEvent($GUI_EVENT_CLOSE, "GUICtrlMsg")           ;注册窗口关闭事件到函数GUICtrlMsg
$Button[14] = GUICtrlCreateButton("登陆", 0, 0, 100, 50,$BS_DEFPUSHBUTTON)
$Button[15] = GUICtrlCreateButton("取消", 110, 0, 100, 50,$BS_DEFPUSHBUTTON);创建子窗口中按钮二

$WinSub5  = GUICreate("网络测试", 220, 60)                ;创建子窗口2
GUISetOnEvent($GUI_EVENT_CLOSE, "GUICtrlMsg")           ;注册窗口关闭事件到函数GUICtrlMsg
$Button[16] = GUICtrlCreateButton("内网测试", 0, 0, 100, 50,$BS_DEFPUSHBUTTON)
$Button[17] = GUICtrlCreateButton("外网测试", 110, 0, 100, 50,$BS_DEFPUSHBUTTON);创建子窗口中按钮二

$WinSub6  = GUICreate("路由系统", 220, 60)                ;创建子窗口2
GUISetOnEvent($GUI_EVENT_CLOSE, "GUICtrlMsg")           ;注册窗口关闭事件到函数GUICtrlMsg
$Button[18] = GUICtrlCreateButton("进入WEB管理平台", 0, 0, 100, 50,$BS_DEFPUSHBUTTON)
$Button[19] = GUICtrlCreateButton("进入监控页面", 110, 0, 100, 50,$BS_DEFPUSHBUTTON);创建子窗口中按钮二

$WinSub7  = GUICreate("系统垃圾清理", 220, 60)                ;创建子窗口2
GUISetOnEvent($GUI_EVENT_CLOSE, "GUICtrlMsg")           ;注册窗口关闭事件到函数GUICtrlMsg
$Button[20] = GUICtrlCreateButton("开始", 0, 0, 100, 50,$BS_DEFPUSHBUTTON)
$Button[21] = GUICtrlCreateButton("退出", 110, 0, 100, 50,$BS_DEFPUSHBUTTON);创建子窗口中按钮二

$WinSub8  = GUICreate("论坛入口", 220, 60)                ;创建子窗口2
GUISetOnEvent($GUI_EVENT_CLOSE, "GUICtrlMsg")           ;注册窗口关闭事件到函数GUICtrlMsg
$Button[22] = GUICtrlCreateButton("登陆", 0, 0, 100, 50,$BS_DEFPUSHBUTTON)
$Button[23] = GUICtrlCreateButton("取消", 110, 0, 100, 50,$BS_DEFPUSHBUTTON);创建子窗口中按钮二

For $I = 39 to 0 Step -1
        GUICtrlSetOnEvent($Button[$I],"GUICtrlMsg") ;注册总共的六个按钮点击事件到函数 GUICtrlMsg
                                                    ;请区分 GUISetOnEvent 和 GUICtrlSetOnEvent的区别
Next

GUISwitch($WinMain)                            ;切换当前窗口到主窗口
GUISetState(@SW_SHOW)                          ;显示当前窗口

While 1
        $Label_time= GUICtrlCreateLabel("Label2", 185, 262, 110, 18)
        GUISetState(@SW_SHOW)
        GUICtrlSetData($Label_time,@HOUR&':'&@MIN&':'&@SEC)

Sleep(1000)

WEnd

Func GUICtrlMsg()
        Switch @GUI_CtrlId;选择事件 ID 或 控件 ID
                Case $GUI_EVENT_CLOSE;如果点下的是$GUI_EVENT_CLOSE(关闭)
                        GUISetState(@SW_HIDE,@GUI_WinHandle);  隐藏产生事件的窗口
                Case $Button[0]
                        GUISetState(@SW_SHOW,$WinSub1);  显示 子窗口 1
                                Case $Button[1]
                        GUISetState(@SW_SHOW,$WinSub2);  隐藏 子窗口 2
                Case $Button[2]
                        GUISetState(@SW_SHOW,$WinSub3);  显示 子窗口 2
                Case $Button[3]
                        GUISetState(@SW_SHOW,$WinSub4);  显示 子窗口 3
                Case $Button[4]
                        GUISetState(@SW_SHOW,$WinSub5);  显示 子窗口 4                                                
                Case $Button[5]
                        GUISetState(@SW_SHOW,$WinSub6);  显示 子窗口 5
                Case $Button[6]
                        GUISetState(@SW_SHOW,$WinSub7);  显示 子窗口 6
                Case $Button[7]
                        GUISetState(@SW_SHOW,$WinSub8);  显示 子窗口 7
                Case $Button[8]
                       _Rundos("start http://192.168.0.136")
                                           GUISetState(@SW_HIDE,$WinSub1);  隐藏 子窗口 1
                                Case $Button[9]
                                           _Rundos("start http://www.fxwlc2624067.51hdwm.com")
                        GUISetState(@SW_HIDE,$WinSub1);  隐藏 子窗口 1
                Case $Button[10]
                        _Rundos("start ftp://192.168.0.136")
                                                GUISetState(@SW_HIDE,$WinSub2);  隐藏 子窗口 2
                                Case $Button[11]
                                                _Rundos("start ftp://192.168.0.254")
                        GUISetState(@SW_HIDE,$WinSub2);  隐藏 子窗口 2
                Case $Button[12]
                                                 _Rundos("start http://192.168.0.136/ly/")
                        GUISetState(@SW_HIDE,$WinSub3);  隐藏 子窗口 2
                Case $Button[13]                                                
                        GUISetState(@SW_HIDE,$WinSub3);  隐藏 子窗口 3
                Case $Button[14]
                        _Rundos("start http://gotogame.com.cn/cybercafe/")
                                                Sleep(1300)
                                                send("{TAB}")
                                                Sleep(100)
                                                send("{TAB}")
                                                sleep(100)
                                                send("admin")
                                                sleep(100)
                                                send("{TAB}")
                                                Sleep(100)
                                                Send("123456")
                                                sleep(200)
                                                send("{TAB}")
                                                GUISetState(@SW_HIDE,$WinSub4);  隐藏 子窗口 4
                Case $Button[15]                                                
                        GUISetState(@SW_HIDE,$WinSub4);  隐藏 子窗口 4
                                Case $Button[16]
                                                _Rundos("start cmd")
                                                Sleep(100)
                        send("ping 192.168.0.1 -t -n 5")
                                                sleep(200)
                                                send("{ENTER}")
                        GUISetState(@SW_HIDE,$WinSub5);  隐藏 子窗口 2
                                Case $Button[17]
                                                _Rundos("start cmd")
                                                Sleep(100)
                        send("ping 202.98.96.68 -t -n 5")
                                            sleep(200)
                                                send("{ENTER}")
                        GUISetState(@SW_HIDE,$WinSub5);  隐藏 子窗口 2
                Case $Button[18]
                        _Rundos("start http://192.168.0.1:8081/nbr.htm")
                                                Sleep(300)
                                                Send("admin")
                                                Sleep(100)
                                                Send("{TAB}")
                                                send("dxrootfx")
                                                Sleep(100)
                                                send("{ENTER}")
                                                GUISetState(@SW_HIDE,$WinSub6);  隐藏 子窗口 6
                Case $Button[19]                                                
                        _Rundos("start http://192.168.0.1:8081/web_moni ... =web_monitor_syslog")
                                                Sleep(300)
                                                Send("admin")
                                                Sleep(100)
                                                Send("{TAB}")
                                                send("123456")
                                                Sleep(100)
                                                send("{ENTER}")
                                                GUISetState(@SW_HIDE,$WinSub6);  隐藏 子窗口 6
                                        Case $Button[20]
                                                Run(@ComSpec & " /c " & "del /f /s /q %SystemRoot%\temp\*.*", "", @SW_HIDE)
                        Run(@ComSpec & " /c " & "del /f /s /q %systemdrive%\*.tmp", "", @SW_HIDE)
                        Run(@ComSpec & " /c " & "del /f /s /q %systemdrive%\*._mp", "", @SW_HIDE)
                        Run(@ComSpec & " /c " & "del /f /s /q %systemdrive%\*.log", "", @SW_HIDE)
                        Run(@ComSpec & " /c " & "del /f /s /q %systemdrive%\*.gid", "", @SW_HIDE)
                        Run(@ComSpec & " /c " & "del /f /s /q %systemdrive%\*.chk", "", @SW_HIDE)
                        Run(@ComSpec & " /c " & "del /f /s /q %systemdrive%\*.old", "", @SW_HIDE)
                        Run(@ComSpec & " /c " & "del /f /s /q %systemdrive%\recycled\*.*", "", @SW_HIDE)
                        Run(@ComSpec & " /c " & "del /f /s /q %windir%\*.bak", "", @SW_HIDE)
                        Run(@ComSpec & " /c " & "del /f /s /q %windir%\prefetch\*.*", "", @SW_HIDE)
                        Run(@ComSpec & " /c " & "rd /s /q %windir%\temp & md %windir%\temp", "", @SW_HIDE)
                        Run(@ComSpec & " /c " & "rem del /f /q %userprofile%\cookies\*.*", "", @SW_HIDE)
                        Run(@ComSpec & " /c " & "del /f /s /q %userprofile%\recent\*.*", "", @SW_HIDE)
                        Run(@ComSpec & " /c " & "del /f /s /q %userprofile%\Local Settings\Temporary Internet Files\*.*", "", @SW_HIDE)
                        Run(@ComSpec & " /c " & "del /f /s /q %userprofile%\Local Settings\Temp\*.*", "", @SW_HIDE)
                        Run(@ComSpec & " /c " & "del /f /s /q %userprofile%\recent\*.*", "", @SW_HIDE)
                        msgbox(48,"by:Jycel QQ:472891322 Emial:jycel@qq.com","提示:清除系统垃圾完成!")
                                                GUISetState(@SW_HIDE,$WinSub7);  隐藏 子窗口 7
                Case $Button[21]                                                
                        GUISetState(@SW_HIDE,$WinSub7);  隐藏 子窗口 7
                                Case $Button[22]
                                                _Rundos("\\192.168.0.136\update$\au3\logAU3.exe")
                        GUISetState(@SW_HIDE,$WinSub8);  隐藏 子窗口 8
                Case $Button[23]
                        GUISetState(@SW_HIDE,$WinSub8);  隐藏 子窗口 8
                                Case $Button[24]
                                                $CD= GUICtrlRead($an[2])
                        Run(@ComSpec & " /c " & 'start http://www.gougou.com/search?search=' & $CD, "", @SW_HIDE)
                                Case $Button[25]
                                                $CD= GUICtrlRead($an[2])
                                                Run(@ComSpec & " /c " & 'start http://web.gougou.com/search?search=' & $CD, "", @SW_HIDE)
                                Case $Button[26]
                                                $CD= GUICtrlRead($an[2])
                        Run(@ComSpec & " /c " & 'start http://movie.gougou.com/search?search=' & $CD, "", @SW_HIDE)
                                Case $Button[27]
                                                $CD= GUICtrlRead($an[2])
                                                Run(@ComSpec & " /c " & 'start http://video.gougou.com/search?s=' & $CD, "", @SW_HIDE)
                                Case $Button[28]
                                                $CD= GUICtrlRead($an[2])
                        Run(@ComSpec & " /c " & 'start http://mp3.gougou.com/search?search=' & $CD, "", @SW_HIDE)
                                Case $Button[29]
                                                $CD= GUICtrlRead($an[2])
                                                Run(@ComSpec & " /c " & 'start http://pic.gougou.com/search?search=' & $CD, "", @SW_HIDE)
                                Case $Button[30]
                                                $CD= GUICtrlRead($an[2])
                        Run(@ComSpec & " /c " & 'start http://www.gougou.com/search?search=' & $CD, "", @SW_HIDE)
                                Case $Button[31]
                                                $CD= GUICtrlRead($an[2])
                                                Run(@ComSpec & " /c " & 'start http://soft.gougou.com/search?search=' & $CD, "", @SW_HIDE)
                                Case $Button[32]
                                                $CD= GUICtrlRead($an[2])
                        Run(@ComSpec & " /c " & 'start http://game.gougou.com/search?search=' & $CD, "", @SW_HIDE)
                                Case $Button[33]
                                                $CD= GUICtrlRead($an[2])
                                                Run(@ComSpec & " /c " & 'start http://blog.gougou.com/search?search=' & $CD, "", @SW_HIDE)
                Case $Button[34]
                                                $CD= GUICtrlRead($an[2])
                                                Run(@ComSpec & " /c " & 'start http://mp3.gougou.com/lrc?search=' & $CD, "", @SW_HIDE)                                                                
                                Case $Button[35]
                                                $CD= GUICtrlRead($an[2])
                                                Run(@ComSpec & " /c " & 'start http://zhidao.baidu.com/?t=50&q=' & $CD, "", @SW_HIDE)                
                                Case $Button[36]
                                                $CD= GUICtrlRead($an[2])
                                                Run(@ComSpec & " /c " & 'start http://news.baidu.com/ns?word=' & $CD, "", @SW_HIDE)                        
                Case $Button[37]
                                                $CD= GUICtrlRead($an[2])
                                                Run(@ComSpec & " /c " & 'start http://tieba.baidu.com/f?kw=' & $CD, "", @SW_HIDE)                                                                        
                                                
                                                
        EndSwitch
EndFunc                                        


Func _Exit()
        Exit
EndFunc


[ 本帖最后由 jycel 于 2009-3-10 16:29 编辑 ]
发表于 2009-3-10 15:51:29 | 显示全部楼层
再While 1 中 删除GUISetState(@SW_SHOW)
发表于 2009-3-10 15:52:50 | 显示全部楼层
adlibenable 很简单阿 看帮助 就知道怎么用了
 楼主| 发表于 2009-3-10 16:23:31 | 显示全部楼层
我重新改了下,在前面定一个标签
$Label2= GUICtrlCreateLabel("Label2", 185, 262, 110, 18)
把GUICtrlSetData($Label2,@HOUR&':'&@MIN&':'&@SEC)这句放到while和wend中间
都测试了下,全没问题了!谢谢楼上朋友哈!
发表于 2012-12-28 14:24:17 | 显示全部楼层
不错顶起。。。。adlibenable这个函数好像找不到么
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-29 15:21 , Processed in 0.103304 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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