找回密码
 加入
搜索
查看: 1216|回复: 2

如何判断telnet窗口不存在,并弹出错误信息

[复制链接]
发表于 2009-2-1 21:35:11 | 显示全部楼层 |阅读模式
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
HotKeySet("{F8}","ports")
GUICreate("中兴交换机开端口程序",450,450)
$telnet=GUICtrlCreateInput("10.",120,30,200,20)
GUICtrlCreateLabel("请输入ip地址:",5,30,110,20)
$b=GUICtrlCreateButton("登陆按钮",350,30,60,20)
$login=GUICtrlCreateInput("",120,60,200,20)
GUICtrlCreateLabel("请输入登陆用户名:",5,60,110,20)
$password=GUICtrlCreateInput("",120,90,200,20)
GUICtrlCreateLabel("请输入login密码:",5,90,110,20)
$enable=GUICtrlCreateInput("",120,120,200,20)
GUICtrlCreateLabel("请输入enable密码:",5,120,110,20)
$port=GUICtrlCreateInput("",120,150,200,20)
GUICtrlCreateLabel("请输入要开的端口:",5,150,110,20)
GUISetState(@SW_SHOW)
Func ports()
        $s=WinGetHandle("Telnet","")
        WinActivate($s)
send(GUICtrlRead($login) & "{enter}" & GUICtrlRead($password) & "{enter}" & "enable" & "{enter}" & GUICtrlRead($enable) & "{enter}")
send("set port " & GUICtrlRead($port) & " enable" & "{enter}" & "save" & "{enter}")
  EndFunc
while 1
        $msg=GUIGetMsg()
        select
                case $msg=$gui_event_close
                        ExitLoop
                case $msg=$b
                        run("telnet " & GUICtrlRead($telnet))
        EndSelect
        WEnd

[ 本帖最后由 bin0131 于 2009-2-3 21:24 编辑 ]
 楼主| 发表于 2009-2-2 08:13:33 | 显示全部楼层
现在是telnet成功后窗口能激活,我问的是telnet窗口不存在时如何弹出错误信息
 楼主| 发表于 2009-2-2 16:37:55 | 显示全部楼层
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
GUICreate("中兴交换机开端口程序",450,450)
$telnet=GUICtrlCreateInput("10.",120,30,200,20)
GUICtrlCreateLabel("请输入ip地址:",5,30,110,20)
$b=GUICtrlCreateButton("开端口按钮",350,30,80,30)
$login=GUICtrlCreateInput("",120,60,200,20)
GUICtrlCreateLabel("请输入登陆用户名:",5,60,110,20)
$password=GUICtrlCreateInput("",120,90,200,20)
GUICtrlCreateLabel("请输入telnet密码:",5,90,110,20)
$enable=GUICtrlCreateInput("",120,120,200,20)
GUICtrlCreateLabel("请输入enable密码:",5,120,110,20)
$port=GUICtrlCreateInput("",120,150,200,20)
GUICtrlCreateLabel("请输入要开的端口:",5,150,110,20)
GUISetState(@SW_SHOW)
Func ports()
     $s=ping(GUICtrlRead($telnet),200)
           if $s Then
        run("telnet " & GUICtrlRead($telnet))
        WinActivate("Telnet","")
   send(GUICtrlRead($login) & "{enter}" & GUICtrlRead($password) & "{enter}" & "enable" & "{enter}" & GUICtrlRead($enable) & "{enter}")
   send("set port " & GUICtrlRead($port) & " enable" & "{enter}" & "save" & "{enter}")
Else
        MsgBox(0,"交换机状态","设备不通")
        EndIf
  EndFunc
while 1
        $msg=GUIGetMsg()
        select
                case $msg=$gui_event_close
                        ExitLoop
                case $msg=$b
                     ports()  
        EndSelect
        WEnd
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-18 19:48 , Processed in 0.074431 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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