Thank you again
JSB but it wouldn't work for me.
I've only started looking at this today, but I need some help.
This is the example code I've copied.
What I would like to do is act on the data that is retrieved from the session.
Dump seems to be the key more than updatelog, but I've no idea how to proceed with this.
I have seen other users posting questions similar to mine, but none quite the same and they've not always posted back their results.
How do I get either dump or log pushing it's data into a var that I can then act upton.
thank you for taking the time to reply.
Martin
Code:
OnExit, CleanUp
Server := "route-server.ip.att.net:23"
log := ""
;~ Debugwindow
Gui,Add,Edit,ReadOnly w800 h400 hwndLogHwnd
Gui,Show,,debug
UpdateLog("Start`n")
Gosub, Ws2_Init
res := expect(socket,"Username:")
if (res>0) {
send(socket,"rviews")
} else if (res<0) {
MsgBox Abortet by force
ExitApp
} else {
MsgBox Fail!
ExitApp
}
res := expect(socket,"route-server>")
if (res>0) {
send(socket,"ping 4.2.2.2")
} else if (res<0) {
MsgBox Abortet by force
ExitApp
} else {
MsgBox Fail!
ExitApp
}
; Skipped, since this will do when GUI is removed :)
;~ Gosub, WS2_CleanUp
return
; Abort with escape
esc::
e_timeout := -1
return
GuiClose:
CleanUp:
Gosub, WS2_CleanUp
ExitApp
WS2_CleanUp:
WS2_CleanUp()
return
ws2_init:
socket := WS2_Connect(Server)
if ((socket<=0) || (StrLen(__WSA_ErrMsg)) || (StrLen(socket)=0)) {
MsgBox,16,%A_ScriptName%: Sock-Error,% __WSA_ErrMsg
Gosub, WS2_CleanUp
}
res := WS2_AsyncSelect(socket,"dump")
if ((Res!=0) || (StrLen(__WSA_ErrMsg))) {
MsgBox,16,%A_ScriptName%: Async-Select-Error,% __WSA_ErrMsg
Gosub, WS2_CleanUp
}
Return
expect(socket,txt,timeout=5000) { ; default timeout 5000 msecs / 0 infinite wait
global e_socket, e_txt, e_timeout := 0
n := 0
Loop,
if ((e_socket=socket) && (RegExMatch(e_txt,txt)) && (n*100<=timeout)) {
e_socket := e_txt := ""
return, 1
} else if (n*100>timeout) {
return, 0
} else {
if (timeout)
n++
sleep, 100
if (e_timeout=-1) {
break
}
}
return -1
}
send(socket,senddata,commit="`r`n") {
if ((StrLen(SendData)>0) && (socket!=0))
WS2_SendData(Socket,SendData Commit)
}
dump(Socket,Txt) {
Global
e_socket := socket, e_txt := txt
;UpdateLog("<<< (" socket ") " txt)
UpdateLog(txt)
}
updateLog(log) {
global LogHwnd
ControlSend,,{end},ahk_id %LogHwnd%
Control,EditPaste,%log%,,ahk_id %LogHwnd%
ControlSend,,{end},ahk_id %LogHwnd%
Return, log
}
msgbox, % updateLog(log)
; Get it from here:
; http://www.autohotkey.com/forum/viewtopic.php?t=35575
#include WinSock2.ahk