huoqingpo 发表于 2009-2-18 13:24:42

在au3中使用telnet 的问题

我有一个ulinix 系统我重启它的时候一般都用cmd 然后进telnet进入后重启,每次这个很麻烦
而且有些人不会,我想做一个程序 ·在程序里面写上用户名字和密码 ,有两个按钮 一个重启,一个关机,来控制服务器。我自己写了个 ·实现不了·
我这个是用自动输入完成的,但是无法自动获得文本框里面的数据,send 输入不出来
那位大哥给帮个忙 看下·怎么解决 或者用其他的办法

#include <ButtonConstants.au3>
_Main()

Func _Main()
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=C:\Documents and Settings\Administrator\桌面\工作\VND\Form1.kxf
$Form1 = GUICreate("VN服务器重启工具 安信", 280, 190, 192, 124)
$Label1 = GUICtrlCreateLabel("用户名", 32, 24, 52, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("密码", 40, 64, 36, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$text1 = GUICtrlCreateInput("", 112, 24, 121, 21)
$text2 = GUICtrlCreateInput("", 112, 64, 121, 21)
$Button1 = GUICtrlCreateButton("重启", 144, 120, 89, 25, 0)
$Button2 = GUICtrlCreateButton("关机", 40, 120, 81, 25, 0)
$Label3 = GUICtrlCreateLabel("", 88, 160, 103, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xFFFFE1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
               
                $msg = GUIGetMsg()

                Select

                        
                        Case $msg = $GUI_EVENT_CLOSE
                              
                              GUIDelete()
                              
                              Exit
                              
                        Case $msg = $Button1
               ShellExecute ("cmd.exe","c:\windows\system32\")
               Sleep (3000)
                                 WinActivate ("c:\windows\system32\")
                                 send ("telnet 192.168.1.246")
               send ("{ENTER}")
                                 Sleep (3000)
               send ($text1)
               send ("{ENTER}")
               Sleep (3000)
               send ($text2)
                                 send ("{ENTER}")
               Sleep (3000)
               send ("init 6")
               Sleep (2000)
                                 send ("{ENTER}")
               WinClose ( "Telnet 192.168.1.246")
               msgbox (0,"安信提示","成功重启服务器三秒自动关闭",3)
                                 
                        Case $msg = $Button2
               ShellExecute ("cmd.exe","c:\windows\system32\")
               Sleep (3000)
                                 WinActivate ("c:\windows\system32\")
                                 send ("telnet 192.168.1.246")
               send ("{ENTER}")
                                 Sleep (3000)
               send ($text1)
               send ("{ENTER}")
               Sleep (3000)
               send ($text2)
                                 send ("{ENTER}")
               Sleep (3000)
               send ("init 0")
               Sleep (2000)
                                 send ("{ENTER}")
               WinClose ( "Telnet 192.168.1.246")
               msgbox (0,"安信提示","成功关闭服务器三秒自动关闭",3)

                EndSelect

      WEnd
EndFunc   ;==>_Main

huoqingpo 发表于 2009-2-18 18:11:18

大哥哥们谁给帮个忙啊`

xinlu8439 发表于 2009-2-18 23:51:16

你要用到的是StdoutRead, StderrRead, StdinWrite几个函数,Send是不能跟命令行窗口互交的
页: [1]
查看完整版本: 在au3中使用telnet 的问题