为什么不加while循环,界面就一闪而过呢?[已解决]
本帖最后由 newuser 于 2010-4-29 10:29 编辑Opt("GUIOnEventMode",1) ;采用事件模式响应
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("系统工具集 ", 631, 454, 192, 114)
$Group1 = GUICtrlCreateGroup(".exe类", 48, 32, 169, 305)
$Button2 = GUICtrlCreateButton("Windows更新程序", 64, 56, 137, 33)
$Button3 = GUICtrlCreateButton("远程桌面", 64, 96, 137, 33)
$Button4 = GUICtrlCreateButton("系统信息", 64, 136, 137, 33)
$Button5 = GUICtrlCreateButton("文件签名验证程序", 64, 176, 137, 33)
$Button6 = GUICtrlCreateButton("任务管理器", 64, 216, 137, 33)
$Button7 = GUICtrlCreateButton("系统配置实用程序", 64, 256, 137, 33)
$Button8 = GUICtrlCreateButton("磁盘垃圾清理", 64, 296, 137, 33)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup(".msc类", 232, 32, 169, 305)
$Button9 = GUICtrlCreateButton("本地服务设置", 248, 56, 137, 33)
$Button10 = GUICtrlCreateButton("共享文件夹管理器", 248, 96, 137, 33)
$Button11 = GUICtrlCreateButton("磁盘碎片整理", 248, 136, 137, 33)
$Button12 = GUICtrlCreateButton("计算机管理", 248, 176, 137, 33)
$Button13 = GUICtrlCreateButton("磁盘管理", 248, 216, 137, 33)
$Button14 = GUICtrlCreateButton("本地安全设置", 248, 256, 137, 33)
$Button15 = GUICtrlCreateButton("设备管理器", 248, 296, 137, 33)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup(".cpl类(控制面板)", 416, 32, 169, 305)
$Button16 = GUICtrlCreateButton("系统属性", 432, 56, 137, 33)
$Button17 = GUICtrlCreateButton("用户帐户", 432, 96, 137, 33)
$Button18 = GUICtrlCreateButton("自动更新", 432, 136, 137, 33)
$Button19 = GUICtrlCreateButton("网络连接", 432, 176, 137, 33)
$Button20 = GUICtrlCreateButton("区域和语言选项", 432, 216, 137, 33)
$Button21 = GUICtrlCreateButton("添加/删除程序", 432, 256, 137, 33)
$Button22 = GUICtrlCreateButton("Internet属性", 432, 296, 137, 33)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("以上工具也可通过运行执行", 48, 352, 537, 65)
$Input1 = GUICtrlCreateInput("", 64, 376, 337, 21)
$Button1 = GUICtrlCreateButton("运行", 416, 368, 105, 33)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label1 = GUICtrlCreateLabel("感谢hynq2000!仅为练手使用---采十青青橄榄2010.4.27", 216, 424, 320, 66)
$Group5 = GUICtrlCreateGroup("", 32, 20, 569, 455)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
;###########进行事件关联##############
GUICtrlSetOnEvent($Button2,"_SysTools") ;点击$Button2,函数_SysTools响应,注意,不需要书写_SysTools(),而且要用" "将函数括起来
GUICtrlSetOnEvent($Button3,"_SysTools") ;另外注意是GUICtrlSetOnEvent(),不是GUISetOnEvent(),人家可是控件啊 !
GUICtrlSetOnEvent($Button4,"_SysTools")
GUICtrlSetOnEvent($Button5,"_SysTools")
GUICtrlSetOnEvent($Button6,"_SysTools")
GUICtrlSetOnEvent($Button7,"_SysTools")
GUICtrlSetOnEvent($Button8,"_SysTools")
GUICtrlSetOnEvent($Button9,"_SysTools")
GUICtrlSetOnEvent($Button10,"_SysTools")
GUICtrlSetOnEvent($Button11,"_SysTools")
GUICtrlSetOnEvent($Button12,"_SysTools")
GUICtrlSetOnEvent($Button13,"_SysTools")
GUICtrlSetOnEvent($Button14,"_SysTools")
GUICtrlSetOnEvent($Button15,"_SysTools")
GUICtrlSetOnEvent($Button16,"_SysTools")
GUICtrlSetOnEvent($Button17,"_SysTools")
GUICtrlSetOnEvent($Button18,"_SysTools")
GUICtrlSetOnEvent($Button19,"_SysTools")
GUICtrlSetOnEvent($Button20,"_SysTools")
GUICtrlSetOnEvent($Button21,"_SysTools")
GUICtrlSetOnEvent($Button22,"_SysTools")
GUICtrlSetOnEvent($Button1,"_SysTools")
;###########事件关联完毕##############
;###########进入##############
;注意:没有这个循环,界面是一闪而过
While 1
Sleep(1)
WEnd
;###########主循环完毕##############
;###########定义响应事件的函数##############
Func _SysTools()
Switch @GUI_CtrlId ;这是事件模式,别忘了消息模式是 Switch @GUIGetMsg()
Case $Button2 ;开始执行系统的exe文件,一般它们都在\system32目录下
Run(@SystemDir&"\wupdmgr.exe")
Case $Button3
Run(@SystemDir&"\mstsc.exe")
Case $Button4
Run(@SystemDir&"\winmsd.exe")
Case $Button5
Run(@SystemDir&"\sigverif.exe")
Case $Button6
Run(@SystemDir&"\taskmgr.exe")
Case $Button7
Run(@WindowsDir&"\pchealth\helpctr\binaries\Msconfig.exe") ;msconfig命令不在\system32目录下
;Run(@SystemDir&"\tsshutdn.exe") 它是60秒倒计时关机命令
Case $Button8
Run(@SystemDir&"\cleanmgr.exe")
Case $Button9 ;开始执行系统的msc文件,一般它们都在\system32目录下,通过shellexecute执行它们
ShellExecute(@SystemDir&"\services.msc")
Case $Button10
ShellExecute(@SystemDir&"\fsmgmt.msc")
Case $Button11
ShellExecute(@SystemDir&"\dfrg.msc")
Case $Button12
ShellExecute(@SystemDir&"\compmgmt.msc")
Case $Button13
ShellExecute(@SystemDir&"\diskmgmt.msc")
Case $Button14
ShellExecute(@SystemDir&"\secpol.msc")
Case $Button15
ShellExecute(@SystemDir&"\devmgmt.msc")
Case $Button16 ;开始执行系统的cpl文件,一般它们都在\system32目录下,通过control来执行.cpl文件
Run("control sysdm.cpl")
Case $Button17
Run("control userpasswords2")
;Run("control nusrmgr.cpl"),不知道为什么它不好使!
Case $Button18
Run("control wuaucpl.cpl")
Case $Button19
Run("control ncpa.cpl")
Case $Button20
Run("control intl.cpl")
Case $Button21
Run("control appwiz.cpl")
Case $Button22
Run("control inetcpl.cpl")
Case $Button1 ;执行 “运行” 按钮
Run('cmd /c'&GUICtrlRead($input1)) ;刚开始,$Button1就是没有反映,原来是忘记将其进行事件关联了
;RunWait(@ComSpec&" /c "&GUICtrlRead($Input1)) ;参数/c 表示要执行后面的“命令字符串”,而字符串是来自控件$input1内的内容
;问题2:输入 msconfig 怎么不执行呢?
;答:笨蛋!它不在/system32目录下,必须输入绝对路径才能执行,要不然再修改Path把msconfig所在的目录也加上
;问题3:如何执行tasklist后让出现的窗口定住呢?Run('cmd /c pause')只是又打开一个DOS的暂停窗口啊?
;答:其实在$input1内输入“tasklist & pause"就实现了,不过这还是DOS啊!
;cmd /V:ON启用“延迟变量”的意思!
EndSwitch
EndFunc
本帖最后由 水木子 于 2010-4-29 09:08 编辑
这是肯定的啊!没有循环,代码一直往下运行,运行完了就退出了呗!
不过建议楼主可以将延迟时间加长一些 如:Sleep(250) 太快了CUP吃不消 楼上说得好啊,我顶啊 回复 2# 水木子
啊!确实是这样,非常感谢! 同意一楼的观点,... 就不知道AU3怎么才能把CPU%弄低一点! 回复 1# newuser
You great!
页:
[1]