AUTOIT3_网管维护工具测试

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AUTOIT3_网管维护工具测试相关的知识,希望对你有一定的参考价值。

首先要先设计个维护面板,看下图

技术分享技术分享

技术分享设计完以后 把窗口生成器生成的代码 复制到SCITE编辑器里  红色部分就是需要我们写上去的代码

在SCITE里新建一个脚本 然后复制进去
#include <GUIConstants.au3>
#include <Process.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("维护工具", 251, 81, 297, 252)
$Button1 = GUICtrlCreateButton("控制面版", 20, 8, 75, 25, 0)
$Button2 = GUICtrlCreateButton("显示属性", 20, 48, 75, 25, 0)
$Button3 = GUICtrlCreateButton("系统属性", 132, 8, 75, 25, 0)
$Button4 = GUICtrlCreateButton("进程管理", 132, 48, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        RunWait("c:\\windows\\system32\\control.exe"); 打开控制面板
                       
                Case $Button2
                        _rundos("C:\\windows\\system32\\desk.cpl");打开显示属性
                       
                Case $Button3
                        _RunDOS("c:\\windows\\system32\\sysdm.cpl");打开系统属性
                       
                Case $Button4
                        RunWait("c:\\windows\\system32\\taskmgr.exe");打开任务管理器                      
        EndSwitch
WEnd
=============================================================================
留给新手的反思 为什么调用exe文件 用runwait      调用cpl文件用 _rundos??
如果用别的方法可不可以?
我也是新手 希望能和大家一起学习
请大家把帖子顶起来 造福更多的au3新手

技术分享

 

技术分享

 

技术分享

 

技术分享

网管维护工具 扩展版这个作品是上一个的扩展版 看看增加了两个小功能

红色部分是需要添加上的
=======================================================
#include <GUIConstants.au3>
#include <Process.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("维护工具测试1", 315, 204, 278, 206)
$Button1 = GUICtrlCreateButton("系统属性", 8, 8, 75, 25, 0)
$Button2 = GUICtrlCreateButton("显示属性", 8, 56, 75, 25, 0)
$Button3 = GUICtrlCreateButton("进程管理", 8, 104, 75, 25, 0)
$Button4 = GUICtrlCreateButton("控制面板", 112, 8, 75, 25, 0)
$Button5 = GUICtrlCreateButton("命令行", 112, 56, 75, 25, 0)
$Button6 = GUICtrlCreateButton("注册表", 112, 104, 75, 25, 0)
$Button7 = GUICtrlCreateButton("Msconfig", 216, 56, 75, 25, 0)
$Button8 = GUICtrlCreateButton("音量控制", 216, 104, 75, 25, 0)
$Button9 = GUICtrlCreateButton("策略组", 216, 8, 75, 25, 0)
$Input1 = GUICtrlCreateInput("", 8, 148, 121, 25)
$Button10 = GUICtrlCreateButton("运行", 144, 148, 43, 25, 0)
$Button11 = GUICtrlCreateButton("时间日期", 216, 144, 75, 25, 0)
GUICtrlCreateLabel("", 184, 176, 4, 4)
$Label1 = GUICtrlCreateLabel("蝶-友川医夫2007/11", 176, 186, 132, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        Case $Button1
                        _RunDOS(@SystemDir &"\\sysdm.cpl");打开系统属性
                Case $Button2
                        _RunDOS(@SystemDir &"\\desk.cpl");打开显示属性
                Case $Button3
                        Run(@SystemDir &"\\taskmgr.exe");打开任务管理器       
                Case $Button4
                        Run(@SystemDir &"\\control.exe");打开控制面板       
                Case $Button5
                        Run(@SystemDir &"\\cmd.exe");打开命令行
                Case $Button6
                        Run(@WindowsDir &"\\regedit.exe");打开注册表
                Case $Button7
                        Run("C:\\WINDOWS\\pchealth\\helpctr\\binaries\\Msconfig.exe");打开msconfig
                Case $Button8
                        Run(@SystemDir &"\\Sndvol32.exe");打开音量控制程序
                Case $Button9
                        ShellExecute(@SystemDir &"\\gpedit.msc");打开策略组  另一种写法Run(@ComSpec&‘ /c gpedit.msc‘,@SystemDir,@SW_HIDE)
                Case $Button10
                        Run(@ComSpec &" /c"&GUICtrlRead($input1));这里是这个作品的关键 读取文本框里的内容然后运行
                Case $Button11
                        _RunDOS(@SystemDir &"\\timedate.cpl");打开时间日期
                Case $Label1
        EndSwitch
WEnd



==================================================
说明:
这个作品比上个来讲 优化了几处代码 增加了一个读取文本框内容然后运行的机制
运用了au3的库文件 @systemdir==windows\\systemdir  @windowsdir==windows 我的理解库文件就好比是一个快捷方式,用的时候方便一些 不用打那么长的字母
但是我在使用中发现有时候库文件的定位不是那么准确 代码正常的情况下会有时管用有时不管用  这一点请大家注意
还有我的这个代码的按键号码 可能和你生成的按键号码不一致 用的时候改正一下就好了




































































































以上是关于AUTOIT3_网管维护工具测试的主要内容,如果未能解决你的问题,请参考以下文章

PTN 网管运维工具: 领导,请尊重我的专业!

基于AutoIt3的运维工具

福利 | 开源测试工具目录

AutoIt3(AU3)开发的驱动备份工具

AutoIt3(AU3)开发的分辨率快速设置工具

ui自动化__unittest单元测试框架