;######密码版的系统工具####################
;进行密码验证
_CheckPassWords()
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 ###
;###########进行事件关联##############
GUISetOnEvent($gui_event_close,"_Exit") ;错误:将 $ 写成 @
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
;###########响应事件的函数结束##############
;###########定义验证密码的函数##############
Func _CheckPassWords()
Local $MyPassWords="MynameisZGK"
$InputPassWords=InputBox("密码验证","请输入密码:","","*",200,100,@DesktopWidth-600,@DesktopHeight-450,20)
;InputBox("标题","提示","默认内容","密码字符","宽","高","左窗口距离","上窗口距离","密码输入延迟时间")
;*就是让输入的密码字符以星号显示
;@DesktopWidth-600,@DesktopHeight-450,就是让密码输入框居中显示
if @error=0 Then ;@error=0表示返回的字符串有效
If $inputpasswords <> $MyPassWords Then
MsgBox (262144+32,"真遗憾!!!","密码错了,想不起来了?",9)
_Exit()
Else ;密码检查通过
$InputPassWords="" ;进入工具操作界面并清空输入的密码
EndIf
ElseIf @error=1 Then ;@error=1表示用户按了Cancel按钮
MsgBox(262144+32,"","用户按了取消按钮")
_Exit()
ElseIf @error=2 Then ;@error=2表示输入超时
MsgBox (262144+32,"真遗憾!!!","输入口令时间超时",9)
_Exit()
ElseIf @error=3 Then ;输入框显示失败,这通常是由参数失效引起
MsgBox (262144+16,"意外错误!!!","口令输入框显示失败!请重试!",9)
_Exit()
Else
_Exit()
EndIf
EndFunc
;###########严整密码函数结束##############
Func _Exit()
Exit
EndFunc