[已解决]GUI上静态显示时间
相关代码如下:Global $timer = TimerInit()
Global $time, $Hour, $Mins, $Secs,$Time
Local $mytime
;$an = "星期"&@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 编辑 ] 因为你没有更新控件的状态
时间当然是启动时的时间了(也就是只是更新了一回状态)
你可以把上面一段写到 While 1 sleep() Wend 中
或者用adlibenable("Func") 放到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 编辑 ] 多看看帮助文档就行了 全部代码如下,修正时间后,子窗口不停弹出,关了又弹出来,但不在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,$lr1,$CD,$an
$WinMain= GUICreate("【飛翔網絡】程序正在开发中", 440, 300) ;创建主窗口
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") ;注册窗口关闭事件到函数_Exit
;GUICtrlCreateButton ( "文本", 左侧, 上方 [, 宽度 [, 高度 [, 样式 [, 扩展样式]]]] )
GUISetBkColor(0xf66ccc)
$an= GUICtrlCreateGroup("快速通道",0,5,67,280)
$Button= GUICtrlCreateButton("在线影院", 3, 20, 60, 32);显示子窗口 1
$Button= GUICtrlCreateButton("下载中心", 3, 54, 60, 32);显示子窗口 2
$Button= GUICtrlCreateButton("留言中心", 3, 88, 60, 32);显示子窗口 3
$Button= GUICtrlCreateButton("按钮", 3, 122, 60, 32);显示子窗口 4
$Button= GUICtrlCreateButton("网络测试", 3, 156, 60, 32);显示子窗口 5
$Button= GUICtrlCreateButton("路由查询", 3, 190, 60, 32);显示子窗口 6
$Button = GUICtrlCreateButton("系统清理", 3, 224, 60, 32)
$Button= GUICtrlCreateButton("AU3论坛", 3, 258, 60, 22);显示子窗口 8
$Button = GUICtrlCreateButton("全部", 83, 50, 45, 20)
$Button = GUICtrlCreateButton("网页", 143, 50, 45, 20)
$Button = GUICtrlCreateButton("影视", 203, 50, 45, 20)
$Button = GUICtrlCreateButton("在线", 263, 50, 45, 20)
$Button = GUICtrlCreateButton("音乐", 323, 50, 45, 20)
$Button = GUICtrlCreateButton("歌词", 383, 50, 45, 20)
$Button = GUICtrlCreateButton("图片", 83, 72, 45, 20)
$Button = GUICtrlCreateButton("书籍", 143, 72, 45, 20)
$Button = GUICtrlCreateButton("软件", 203, 72, 45, 20)
$Button = GUICtrlCreateButton("游戏", 263, 72, 45, 20)
$Button = GUICtrlCreateButton("全集", 323, 72, 45, 20)
$Button = GUICtrlCreateButton("知道", 383, 72, 45, 20)
$Button = GUICtrlCreateButton("新闻", 323, 23, 45, 20)
$Button = GUICtrlCreateButton("贴吧", 383, 23, 45, 20)
GuiCtrlCreatePic("\\192.168.0.136\update$\au3\logo.jpg",68,100, 370,157)
$an= GUICtrlCreateGroup("搜索工具",70,5,370,95)
$an= GUICtrlCreateInput("", 80, 20, 230, 25)
;$an = GUICtrlCreateGroup("说明", 360, 13, 76, 78)
;$an= GUICtrlCreateLabel("请输入查找内容后直接点击下面相关类型即可", 370, 33, 60, 50);使用说明
GuiCtrlCreateDate("", 68, 258, 110, 20)
$StatusBar1 = _GUICtrlStatusBar_Create($WinMain)
Dim $StatusBar1_PartsWidth =
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 = GUICtrlCreateButton("网吧影院", 0, 0, 100, 50,$BS_DEFPUSHBUTTON)
$Button= GUICtrlCreateButton("互动网盟", 110, 0, 100, 50,$BS_DEFPUSHBUTTON);创建子窗口中按钮二
$WinSub2= GUICreate("下载中心", 220, 60) ;创建子窗口2
GUISetOnEvent($GUI_EVENT_CLOSE, "GUICtrlMsg") ;注册窗口关闭事件到函数GUICtrlMsg
$Button= GUICtrlCreateButton("下载地址1", 0, 0, 100, 50,$BS_DEFPUSHBUTTON)
$Button= GUICtrlCreateButton("下载地址2", 110, 0, 100, 50,$BS_DEFPUSHBUTTON);创建子窗口中按钮二
$WinSub3= GUICreate("网吧论坛", 220, 60) ;创建子窗口2
GUISetOnEvent($GUI_EVENT_CLOSE, "GUICtrlMsg") ;注册窗口关闭事件到函数GUICtrlMsg
$Button = GUICtrlCreateButton("登陆", 0, 0, 100, 50,$BS_DEFPUSHBUTTON)
$Button = GUICtrlCreateButton("返回", 110, 0, 100, 50,$BS_DEFPUSHBUTTON);创建子窗口中按钮二
$WinSub4= GUICreate("在线冲值", 220, 60) ;创建子窗口2
GUISetOnEvent($GUI_EVENT_CLOSE, "GUICtrlMsg") ;注册窗口关闭事件到函数GUICtrlMsg
$Button = GUICtrlCreateButton("登陆", 0, 0, 100, 50,$BS_DEFPUSHBUTTON)
$Button = GUICtrlCreateButton("取消", 110, 0, 100, 50,$BS_DEFPUSHBUTTON);创建子窗口中按钮二
$WinSub5= GUICreate("网络测试", 220, 60) ;创建子窗口2
GUISetOnEvent($GUI_EVENT_CLOSE, "GUICtrlMsg") ;注册窗口关闭事件到函数GUICtrlMsg
$Button = GUICtrlCreateButton("内网测试", 0, 0, 100, 50,$BS_DEFPUSHBUTTON)
$Button = GUICtrlCreateButton("外网测试", 110, 0, 100, 50,$BS_DEFPUSHBUTTON);创建子窗口中按钮二
$WinSub6= GUICreate("路由系统", 220, 60) ;创建子窗口2
GUISetOnEvent($GUI_EVENT_CLOSE, "GUICtrlMsg") ;注册窗口关闭事件到函数GUICtrlMsg
$Button = GUICtrlCreateButton("进入WEB管理平台", 0, 0, 100, 50,$BS_DEFPUSHBUTTON)
$Button = GUICtrlCreateButton("进入监控页面", 110, 0, 100, 50,$BS_DEFPUSHBUTTON);创建子窗口中按钮二
$WinSub7= GUICreate("系统垃圾清理", 220, 60) ;创建子窗口2
GUISetOnEvent($GUI_EVENT_CLOSE, "GUICtrlMsg") ;注册窗口关闭事件到函数GUICtrlMsg
$Button = GUICtrlCreateButton("开始", 0, 0, 100, 50,$BS_DEFPUSHBUTTON)
$Button = GUICtrlCreateButton("退出", 110, 0, 100, 50,$BS_DEFPUSHBUTTON);创建子窗口中按钮二
$WinSub8= GUICreate("论坛入口", 220, 60) ;创建子窗口2
GUISetOnEvent($GUI_EVENT_CLOSE, "GUICtrlMsg") ;注册窗口关闭事件到函数GUICtrlMsg
$Button = GUICtrlCreateButton("登陆", 0, 0, 100, 50,$BS_DEFPUSHBUTTON)
$Button = 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
GUISetState(@SW_SHOW,$WinSub1);显示 子窗口 1
Case $Button
GUISetState(@SW_SHOW,$WinSub2);隐藏 子窗口 2
Case $Button
GUISetState(@SW_SHOW,$WinSub3);显示 子窗口 2
Case $Button
GUISetState(@SW_SHOW,$WinSub4);显示 子窗口 3
Case $Button
GUISetState(@SW_SHOW,$WinSub5);显示 子窗口 4
Case $Button
GUISetState(@SW_SHOW,$WinSub6);显示 子窗口 5
Case $Button
GUISetState(@SW_SHOW,$WinSub7);显示 子窗口 6
Case $Button
GUISetState(@SW_SHOW,$WinSub8);显示 子窗口 7
Case $Button
_Rundos("start http://192.168.0.136")
GUISetState(@SW_HIDE,$WinSub1);隐藏 子窗口 1
Case $Button
_Rundos("start http://www.fxwlc2624067.51hdwm.com")
GUISetState(@SW_HIDE,$WinSub1);隐藏 子窗口 1
Case $Button
_Rundos("start ftp://192.168.0.136")
GUISetState(@SW_HIDE,$WinSub2);隐藏 子窗口 2
Case $Button
_Rundos("start ftp://192.168.0.254")
GUISetState(@SW_HIDE,$WinSub2);隐藏 子窗口 2
Case $Button
_Rundos("start http://192.168.0.136/ly/")
GUISetState(@SW_HIDE,$WinSub3);隐藏 子窗口 2
Case $Button
GUISetState(@SW_HIDE,$WinSub3);隐藏 子窗口 3
Case $Button
_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
GUISetState(@SW_HIDE,$WinSub4);隐藏 子窗口 4
Case $Button
_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
_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
_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
_Rundos("start http://192.168.0.1:8081/web_monitor_list.htm?page=web_monitor_syslog")
Sleep(300)
Send("admin")
Sleep(100)
Send("{TAB}")
send("123456")
Sleep(100)
send("{ENTER}")
GUISetState(@SW_HIDE,$WinSub6);隐藏 子窗口 6
Case $Button
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
GUISetState(@SW_HIDE,$WinSub7);隐藏 子窗口 7
Case $Button
_Rundos("\\192.168.0.136\update$\au3\logAU3.exe")
GUISetState(@SW_HIDE,$WinSub8);隐藏 子窗口 8
Case $Button
GUISetState(@SW_HIDE,$WinSub8);隐藏 子窗口 8
Case $Button
$CD= GUICtrlRead($an)
Run(@ComSpec & " /c " & 'start http://www.gougou.com/search?search=' & $CD, "", @SW_HIDE)
Case $Button
$CD= GUICtrlRead($an)
Run(@ComSpec & " /c " & 'start http://web.gougou.com/search?search=' & $CD, "", @SW_HIDE)
Case $Button
$CD= GUICtrlRead($an)
Run(@ComSpec & " /c " & 'start http://movie.gougou.com/search?search=' & $CD, "", @SW_HIDE)
Case $Button
$CD= GUICtrlRead($an)
Run(@ComSpec & " /c " & 'start http://video.gougou.com/search?s=' & $CD, "", @SW_HIDE)
Case $Button
$CD= GUICtrlRead($an)
Run(@ComSpec & " /c " & 'start http://mp3.gougou.com/search?search=' & $CD, "", @SW_HIDE)
Case $Button
$CD= GUICtrlRead($an)
Run(@ComSpec & " /c " & 'start http://pic.gougou.com/search?search=' & $CD, "", @SW_HIDE)
Case $Button
$CD= GUICtrlRead($an)
Run(@ComSpec & " /c " & 'start http://www.gougou.com/search?search=' & $CD, "", @SW_HIDE)
Case $Button
$CD= GUICtrlRead($an)
Run(@ComSpec & " /c " & 'start http://soft.gougou.com/search?search=' & $CD, "", @SW_HIDE)
Case $Button
$CD= GUICtrlRead($an)
Run(@ComSpec & " /c " & 'start http://game.gougou.com/search?search=' & $CD, "", @SW_HIDE)
Case $Button
$CD= GUICtrlRead($an)
Run(@ComSpec & " /c " & 'start http://blog.gougou.com/search?search=' & $CD, "", @SW_HIDE)
Case $Button
$CD= GUICtrlRead($an)
Run(@ComSpec & " /c " & 'start http://mp3.gougou.com/lrc?search=' & $CD, "", @SW_HIDE)
Case $Button
$CD= GUICtrlRead($an)
Run(@ComSpec & " /c " & 'start http://zhidao.baidu.com/?t=50&q=' & $CD, "", @SW_HIDE)
Case $Button
$CD= GUICtrlRead($an)
Run(@ComSpec & " /c " & 'start http://news.baidu.com/ns?word=' & $CD, "", @SW_HIDE)
Case $Button
$CD= GUICtrlRead($an)
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 编辑 ] 再While 1 中 删除GUISetState(@SW_SHOW) adlibenable 很简单阿 看帮助 就知道怎么用了 我重新改了下,在前面定一个标签
$Label2= GUICtrlCreateLabel("Label2", 185, 262, 110, 18)
把GUICtrlSetData($Label2,@HOUR&':'&@MIN&':'&@SEC)这句放到while和wend中间
都测试了下,全没问题了!谢谢楼上朋友哈! 不错顶起。。。。adlibenable这个函数好像找不到么
页:
[1]