BrettF Posted May 20, 2007 Posted May 20, 2007 Well, since the RAP seems to be dying, even though it seems just Manadar and a few others still want it to be around (or are still working on it). I was experimenting with changing Lar's binary TCP transfer, to send a msg ("screencap") to the sender of a jpg, capturing the image, then sending it back to the receiver of the jpg. I've got something happening, but I'm not sure why recv.au3 seems to freeze when send.au3 is started? Here is my code. If it's so wrong its almost usless to fix, tell me. I'll get this TCP thingo one day... Recv.au3: expandcollapse popup;recv.au3 - run first Global $buffer, $d = -1 TCPStartup() $MSock = TCPListen(@ipaddress1,3333) $sock = -1 While $sock = -1 $sock = TCPAccept($MSock) Sleep(100) ToolTip("1") WEnd While 1 While $d = -1 TCPSend ($MSock, "screencap") If Not @error Then MsgBox (0, "Sent", "ScreencapSent") $d = 1 ExitLoop EndIf WEnd $buffer = Binary($buffer) $f = TCPRecv($sock,65535) If @error Then ExitLoop $buffer &= $f Sleep(100) WEnd FileDelete(".\screen.jpg") $a = FileOpen(".\screen.jpg",18) FileWrite($a,$buffer) FileClose($a) TCPShutdown() oÝ÷ Ù'§u«·jëh×6 ;send.au3 - run second TCPStartup() $sock = TCPConnect(@IPAddress1,3333) If $sock = -1 Then Exit While 1 $Recv = TCPRecv ($sock, 100) If $Recv = "screencap" Then MsgBox (0, "". $Recv) DllCall("captdll.dll", "int", "CaptureScreen", "str", "screen.jpg", "int", 85) $a = FileOpen(".\screen.jpg",16) $buffer = FileRead($a) FileClose($a) While BinaryLen($buffer) $a = TCPSend($sock,$buffer) Sleep(100) $buffer = BinaryMid($buffer,$a+1,BinaryLen($buffer)-$a) WEnd EndIf WEnd TCPShutdown() Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
Gif Posted May 20, 2007 Posted May 20, 2007 Well, since the RAP seems to be dying, even though it seems just Manadar and a few others still want it to be around (or are still working on it). I was experimenting with changing Lar's binary TCP transfer, to send a msg ("screencap") to the sender of a jpg, capturing the image, then sending it back to the receiver of the jpg. I've got something happening, but I'm not sure why recv.au3 seems to freeze when send.au3 is started? Here is my code. If it's so wrong its almost usless to fix, tell me. I'll get this TCP thingo one day... Recv.au3: expandcollapse popup;recv.au3 - run first Global $buffer, $d = -1 TCPStartup() $MSock = TCPListen(@ipaddress1,3333) $sock = -1 While $sock = -1 $sock = TCPAccept($MSock) Sleep(100) ToolTip("1") WEnd While 1 While $d = -1 TCPSend ($MSock, "screencap") If Not @error Then MsgBox (0, "Sent", "ScreencapSent") $d = 1 ExitLoop EndIf WEnd $buffer = Binary($buffer) $f = TCPRecv($sock,65535) If @error Then ExitLoop $buffer &= $f Sleep(100) WEnd FileDelete(".\screen.jpg") $a = FileOpen(".\screen.jpg",18) FileWrite($a,$buffer) FileClose($a) TCPShutdown() oÝ÷ Ù'§u«·jëh×6 ;send.au3 - run second TCPStartup() $sock = TCPConnect(@IPAddress1,3333) If $sock = -1 Then Exit While 1 $Recv = TCPRecv ($sock, 100) If $Recv = "screencap" Then MsgBox (0, "". $Recv) DllCall("captdll.dll", "int", "CaptureScreen", "str", "screen.jpg", "int", 85) $a = FileOpen(".\screen.jpg",16) $buffer = FileRead($a) FileClose($a) While BinaryLen($buffer) $a = TCPSend($sock,$buffer) Sleep(100) $buffer = BinaryMid($buffer,$a+1,BinaryLen($buffer)-$a) WEnd EndIf WEnd TCPShutdown() oÝ÷ Ûú®¢×°zYazZp¢é]vß}÷m0ç/ý¶®¶scµ4U%dU"b333²b333²7F'BÖRf'7Bb333²b333²b333²b333²b333²b333²b333²b333²b333²b333²b333²b333²b333²b333²b333°¢6æ6ÇVFRfÇC´uT6öç7FçG2æS2fwC° £²6WB6öÖR&WW6&ÆRæfð£²6WB÷W"V&Æ2FG&W72FG&W73W&Rà¤FÒb33c·7¤DE$U52ÒFG&W73¤FÒb33c¶åõ%BÒ33 £²7F'BFRD56W'f6W0£³ÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÐ¥D57F'EW £²7&VFRÆ7FVæærgV÷Cµ4ô4´UBgV÷C²à£²W6ær÷W"FG&W72æB÷'B33ࣳÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓТb33c´Öå6ö6¶WBÒD5Æ7FVâb33c·7¤DE$U52Âb33c¶åõ%B £²bFR6ö6¶WB7&VFöâfÇ2ÂWBà¤bb33c´Öå6ö6¶WBÒÓFVâW@ £²7&VFRuTf÷"ÖW76vW0£³ÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓФFÒb33c´tôôUÒuT7&VFRgV÷C´×6W'fW"¢gV÷C²fײb33c·7¤DE$U52fײgV÷C²gV÷C²Ã3Ã#¤FÒb33c¶VFBÒuT7G&Ä7&VFTVFBgV÷C²gV÷C²ÃÃÃ#äuT6WE7FFR £²æFƦRf&&ÆRFò&W&W6VçB6öææV7FöࣳÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓФFÒb33c´6öææV7FVE6ö6¶WBÒÓ £µvBf÷"æB66WB6öææV7FöࣳÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓФFð¢b33c´6öææV7FVE6ö6¶WBÒD566WBb33c´Öå6ö6¶WB¥VçFÂb33c´6öææV7FVE6ö6¶WBfÇC²fwC²Ó £²vWBöb6ÆVçB6öææV7Fæp¤FÒb33c·7¤ô66WFVBÒ6ö6¶WEFôb33c´6öææV7FVE6ö6¶WB ¤FÒb33c¶×6rÂb33c·&V7`£²uTÖW76vRÆö÷£³ÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÓÐ¥vÆR¢b33c¶×6rÒuTvWD×6r £²uT6Æ÷6V@£²ÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒТbb33c¶×6rÒb33c´uTôUdTåEô4Äõ4RFVâWDÆö÷ £²G'Fò&V6VfRWFò#C'FW0£²ÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒТb33c·&V7bÒD5&V7bb33c´6öææV7FVE6ö6¶WBÂ#C¢£²bFR&V6VfRfÆVBvFW'&÷"FVâFR6ö6¶WB2F66öææV7FV@£²ÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒТbW'&÷"FVâWDÆö÷ £²WFFRFRVFB6öçG&öÂvFvBvRfR&V6VfV@£²ÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒТbb33c·&V7bfÇC²fwC²gV÷C²gV÷C²FVâuT7G&Å6WDFFb33c¶VFBÂð¢b33c·7¤ô66WFVBfײgV÷C²fwC²gV÷C²fײb33c·&V7bfײ5$ÄbfײuT7G&Å&VBb33c¶VFB¥tVæ@ ¤bb33c´6öææV7FVE6ö6¶WBfÇC²fwC²ÓFVâD56Æ÷6U6ö6¶WBb33c´6öææV7FVE6ö6¶WB ¥D56WDF÷vâ £²gVæ7FöâFò&WGW&âFG&W72g&öÒ6öææV7FVB6ö6¶WBࣲÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒФgVæ26ö6¶WEFôb33cµ4ô4´UB¢Æö6Âb33c·6ö6¶FG"ÒDÄÅ7G'V7D7&VFRgV÷C·6÷'C·W6÷'C·VçC¶6%³ÒgV÷C² ¢Æö6Âb33c¶&WBÒDÄÄ6ÆÂgV÷Cµw3%ó3"æFÆÂgV÷C²ÂgV÷C¶çBgV÷C²ÂgV÷C¶vWGVW&æÖRgV÷C²ÂgV÷C¶çBgV÷C²Âb33cµ4ô4´UBÂð¢gV÷C·G"gV÷C²ÄDÄÅ7G'V7DvWEG"b33c·6ö6¶FG"ÂgV÷C¶çE÷G"gV÷C²ÄDÄÅ7G'V7DvWE6¦Rb33c·6ö6¶FG"¢bæ÷BW'&÷"æBb33c¶&WE³ÒÒFVà¢b33c¶&WBÒDÄÄ6ÆÂgV÷Cµw3%ó3"æFÆÂgV÷C²ÂgV÷C·7G"gV÷C²ÂgV÷C¶æWEöçFögV÷C²ÂgV÷C¶çBgV÷C²ÄDÄÅ7G'V7DvWDFFb33c·6ö6¶FG"Ã2¢bæ÷BW'&÷"FVâb33c¶&WBÒb33c¶&WE³Ð¢VÇ6P¢b33c¶&WBÒ¢VæD` ¢b33c·6ö6¶FG"Ò ¢&WGW&âb33c¶&W@¤VæDgVæ0
ShaneHale Posted May 20, 2007 Posted May 20, 2007 Not seeing how the help file example - at least "as-is" - helps in this situation. It transfers characters typed into input box to a remote machine. It does it well too I have tried it effectively. What it does not do is send a binary like a image file or and executable. I am sure it could be modified but not exactly sure how. I have been trying this for several days. In the end I would just like to see an example of a file transfer that will work. Files like jpg's, exe's, zip's etc. not just charachters into an input box. I have tryed Larry's example and several others for trasnsfering files but none seem to work over the internet. They all (mostly) work on the same machine but hw does that help? Larry's comes the closest. It just changes the file size of the jpeg but it does connect and it does create a file. In fact it does not seem to matter what type of file it consistantly adds to the size of the file in the transfer process. At least for me. It may be the difference int he script (my changes) which other than the ip target are minior. I am changing the .\somefile.exe to c:\somefile.exe - perhaps this is where I am screwing it up ? Please help...
jvanegmond Posted May 20, 2007 Posted May 20, 2007 (edited) Well, this works in a browser. I was making this for some sort of WebVNC, which is coming along quite nicely. I have only done it with a webcam image, not with a screenshot. I'm always getting a stack overflow error... Kind of annoying, and I am yet to fix it. By the way, you start this script and then enter 'http://your.computer.ip.something/' into the address bar of your preferred browser. expandcollapse popup#include <Misc.au3> If Not _Singleton("WebScreen Manadar") Then Exit EndIf TCPStartup() ;Set up the variables $MaxClient = 12 Dim $Socket[$MaxClient] Dim $Buffer[$MaxClient] For $x = 0 to UBound($Socket)-1 ; fills the socket array with -1 for error checking $Socket[$x] = -1 Next Dim $IP = @IPAddress1 Dim $Port = 80 ; the listening port TCPStartup() $MainSocket = TCPListen($IP,$Port) ;create main listening socket If @error Then MsgBox(0, "", "Can't listen") ; can't create socket, error out. Exit EndIf While 1 ; accepting incoming connections $NewSocket = TCPAccept($MainSocket) If $NewSocket >= 0 Then For $x = 0 to UBound($Socket)-1 If $Socket[$x] = -1 Then $Socket[$x] = $NewSocket ;store the new socket ExitLoop EndIf Next EndIf For $x = 0 to UBound($Socket)-1 ;receiving loop If $Socket[$x] <> -1 Then $NewData = TCPRecv($Socket[$x],1024) If @error Then $Socket[$x] = -1 ElseIf $NewData Then ; data received $Buffer[$x] &= $NewData ;store it in the buffer If StringInStr(StringStripCR($Buffer[$x]),@LF&@LF) Then $FirstLine = StringLeft($Buffer[$x],StringInStr($Buffer[$x],@LF)) $RequestType = StringLeft($FirstLine,StringInStr($FirstLine," ")-1) If $RequestType = "GET" Then $Request = StringTrimRight(StringTrimLeft($FirstLine,4),11) If $Request = "/" Then $Packet = Binary("HTTP/1.1 200 OK" & @CRLF & _ "Server: ManadarX/1.3.26 (" & @OSVersion & ") AutoIt " & @AutoItVersion & @CRLF & _ "Connection: close" & @CRLF & _ "Content-Type: text/html" & @CRLF & _ @CRLF & _ '<img src="screen.jpg">' & _ @LF & _ @LF) TCPSend($Socket[$x],$Packet) Else ; ################################ ; TWEAK ME!!!!!! FileDelete("screen.jpg") DllCall("captdll.dll", "int", "CaptureScreen", "str", "screen.jpg", "int", 85) ; end of TWEAK ME!!!!!! ; ################################ $File = FileOpen("screen.jpg",16) $JPEGBuffer = FileRead($File) FileClose($File) FileDelete("scnshot.bmp") $Packet = Binary("HTTP/1.1 200 OK" & @CRLF & _ "Server: ManadarX/1.3.26 (" & @OSVersion & ") AutoIt " & @AutoItVersion & @CRLF & _ "Connection: close" & @CRLF & _ "Content-Type: image/jpeg" & @CRLF & _ @CRLF) TCPSend($Socket[$x],$Packet) While BinaryLen($JPEGbuffer) ;Larry's idea to send in chunks $a = TCPSend($Socket[$x],$JPEGbuffer) $JPEGbuffer = BinaryMid($JPEGbuffer,$a+1,BinaryLen($JPEGbuffer)-$a) WEnd $Packet = Binary(@CRLF & _ @CRLF) TCPSend($Socket[$x],$Packet) EndIf EndIf $Buffer[$x] = "" TCPCloseSocket($Socket[$x]) $Socket[$x] = -1 EndIf EndIf EndIf Next WEnd Edited May 20, 2007 by Manadar github.com/jvanegmond
ShaneHale Posted May 21, 2007 Posted May 21, 2007 Thats a nice looking script and if I am reading it right it may come in hady to support folks in a different building here on our campus. However what I am toiling with is sending a file from a client to a server. And really it is a non issue at this point since I am using a commercial product now but I would still like to know how to transfer something from one computer to another purely with autoit. I guess at this point I just am wanting to make a point to myself that it can be done.... It seems that I am so close to haveing it work. It is just an aggrivating annoyance now. Regards, Shane
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now