Thanks
sinkfaze
I understand that, but it just doesn't seem to work for me !
Here is the code. I get the debug window will all the data, but never a message box with anything in that !
That's why I totally confused with this..
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
e_alltxt .= txt . "`n" ; append txt and newline
;UpdateLog("<<< (" socket ") " txt)
UpdateLog(txt)
}
MsgBox % e_socket "`n" e_alltxt
updateLog(log) {
global LogHwnd
ControlSend,,{end},ahk_id %LogHwnd%
Control,EditPaste,%log%,,ahk_id %LogHwnd%
ControlSend,,{end},ahk_id %LogHwnd%
}
; Get it from here:
; http://www.autohotkey.com/forum/viewtopic.php?t=35575
#include WinSock2.ahk
I've just run this code as is, and the 'debug' window is fine lots of data passing by.. But I expected to get a message box with that data in it and nothing happened..
Thanks again for your continued help..
