Opt("TrayIconDebug", 1)
Opt("TCPTimeout", 300)
Opt("GUICloseOnESC", 0)
Opt("GUIOnEventMode",1)
#include <EditConstants.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
$SW = GuiCreate("Connect", 235, 110, @DesktopWidth/2-125, @DesktopHeight/2-75, BitOR($WS_BORDER, $WS_POPUP))
$startIP = GuiCtrlCreateInput("", 15, 35, 200, 21)
$label_1 = GUICtrlCreateLabel("Enter IP-address:", 15, 10, 100, 20)
$connectbutton = GUICtrlCreateButton("Connect", 15, 65, 80, 30, $BS_DEFPUSHBUTTON + $BS_FLAT)
$quitbutton = GUICtrlCreateButton("Quit", 135, 65, 80, 30, $BS_FLAT)
$guidragcontrol = GUICtrlCreatePic("", 0, 0, 235, 110, -1, $GUI_WS_EX_PARENTDRAG)
$TW = GUICreate(" a small telnet (=", 1000, 600, @DesktopWidth/2-500, @DesktopHeight/2-300, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_SYSMENU))
GUISetIcon(@SystemDir & "\cmd.exe")
$input = GUICtrlCreateInput("", 5, 570, 990, 25, -1, $WS_EX_STATICEDGE)
GUICtrlSetFont($input, 16, 800, 0, "Courier New")
$output = GUICtrlCreateEdit("", 5, 5, 990, 560, BitOR($ES_AUTOHSCROLL, $ES_AUTOVSCROLL, $ES_READONLY, $ES_WANTRETURN, $WS_VSCROLL), $WS_EX_STATICEDGE)
GUICtrlSetFont($output, 16, 800, 0, "Courier New")
GUICtrlSetBkColor($output, 0xFFFFFF)
GUISetState(@SW_SHOW, $TW)
GUISetState(@SW_DISABLE, $TW)
GUISetState(@SW_SHOW, $SW)
GUISetOnEvent($GUI_EVENT_CLOSE, "QuitTW", $TW)
GUICtrlSetOnEvent($connectbutton, "Connect")
GUICtrlSetOnEvent($quitbutton, "QuitSW")
Func Connect()
$ip = GUICtrlRead($startIP)
$syntax = StringRegExp($ip, "(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\z)")
If $syntax = 0 Then
MsgBox(0x40000, "Syntax Error", "IP incorrect")
Else
GUISetState(@SW_ENABLE, $TW)
GUISetState(@SW_HIDE, $SW)
GUICtrlSetState($input, $GUI_FOCUS)
TCPStartup()
$socket = TCPConnect($ip, 23)
Sleep(250)
$stream = TCPRecv($socket, 100000)
GUICtrlSetData($output, GUICtrlRead($output) & $stream)
;~ TCPSend($socket, "user" & @CRLF)
;~ Sleep(100)
;~ $stream = TCPRecv($socket, 100000)
;~ GUICtrlSetData($output, GUICtrlRead($output) & $stream)
;~ TCPSend($socket, "pass" & @CRLF)
;~ Sleep(100)
;~ $stream = TCPRecv($socket, 100000)
;~ GUICtrlSetData($output, GUICtrlRead($output) & $stream)
;~ TCPSend($socket, "command" & @CRLF)
;~ Sleep(100)
;~ $stream = TCPRecv($socket, 100000)
;~ GUICtrlSetData($output, GUICtrlRead($output) & $stream)
TCPCloseSocket($socket)
TCPShutdown()
Sleep(3000)
GUISetState(@SW_DISABLE, $TW)
GUICtrlSetState($input, $GUI_FOCUS)
GUICtrlSetData($input, "")
GUICtrlSetData($output, "")
GUISetState(@SW_SHOW, $SW)
EndIf
EndFunc
Func QuitTW()
GUISetState(@SW_DISABLE, $TW)
$ask = MsgBox(0x40004, "Quit", "Leaving?")
If $ask = 6 Then
Exit
Else
GUISetState(@SW_ENABLE, $TW)
GUISetState(@SW_RESTORE, $TW)
EndIf
EndFunc
Func QuitSW()
GUISetState(@SW_DISABLE, $SW)
$ask = MsgBox(0x40004, "Quit", "Leaving?")
If $ask = 6 Then
Exit
Else
GUISetState(@SW_ENABLE, $SW)
GUISetState(@SW_RESTORE, $SW)
EndIf
EndFunc
While 1
Sleep(500)
WEnd