deathkillspt Posted September 7, 2007 Share Posted September 7, 2007 (edited) Ok so i have a client and a server when the client sends the command "desktop" to the server the server takes a screenshot, and sends it to the client, the client then recives the information and assembles the picture out of it...there is a problem though when i go to view the screenshot that the client assembled it doesn't show. i'm trying to be as clear as i can but it's kind of hard for me to explain here is my source. Client: expandcollapse popup#include <GUIConstants.au3> dim $sock #region GUI $frmmain = GUICreate("Send picture", 795, 577, 179, 116) $picdesktop = GUICtrlCreatePic("Capture.jpg", 8, 8, 777, 529, BitOR($SS_NOTIFY,$WS_GROUP)) $txtip = GUICtrlCreateInput("127.0.0.1", 520, 544, 121, 21) $txtport = GUICtrlCreateInput("1337", 648, 544, 57, 21) $btnconnect = GUICtrlCreateButton("Connect", 712, 544, 75, 25, 0) $txtsend = GUICtrlCreateInput("", 8, 544, 161, 21) $btnsend = GUICtrlCreateButton("Send", 176, 544, 75, 25, 0) $lblstatus = GUICtrlCreateLabel("Status: Disconnected", 312, 544, 156, 20) GUISetState(@SW_SHOW) #endregion While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Disconnect() Exit case $btnconnect Connect() case $btnsend SendToServer() EndSwitch Recive() WEnd func Recive();Recive routine $recv = TCPRecv($sock,100000000) if StringInStr($recv,"desktop") Then $temp = StringSplit($recv,":") FileWrite("Screenie.jpg",$temp[2]) EndIf if $recv = "ac" Then GUICtrlSetData($lblstatus,"Status: Connected") EndIf EndFunc func SendToServer();Send routine TCPSend($sock,guictrlread($txtsend)) EndFunc func Connect();Connect routine TCPStartup() $sock = TCPConnect(guictrlread($txtip),guictrlread($txtport)) EndFunc func Disconnect();Disconnect routine TCPSend($sock,"disconnect") TCPCloseSocket($sock) TCPShutdown() EndFunc Server: #include <A3LScreenCap.au3> Global $Connectedsock = -1 Global $sock = -1 Local $ip = "127.0.0.1" Local $port = 1337 TCPStartup() $sock = TCPListen($ip,$port);Wait for connection while 1 $recv = TCPRecv($connectedsock,100000000);Recive the data from the client if $recv = "disconnect" Then $connectedsock = -1 EndIf if $recv = "desktop" Then _ScreenCap_Capture("pic.jpg") $file = FileOpen("pic.jpg",16) $fileread = FileRead($file) FileClose($file) TCPSend($connectedsock,"desktop:" & $fileread) EndIf if $connectedsock = -1 Then;Accept the connection $connectedsock = TCPAccept($sock) if $connectedsock <> - 1 Then TCPSend($connectedsock,"ac") EndIf EndIf WEnd Edited September 7, 2007 by deathkillspt Link to comment Share on other sites More sharing options...
deathkillspt Posted September 7, 2007 Author Share Posted September 7, 2007 Come on someone please help me. Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 7, 2007 Share Posted September 7, 2007 Where, exactly, does it fail? Does the server generate the screenshot file to disk correctly, and that file is usable? Does the file get transferred correctly to the client, and is usable from disk? Does the graphical code on the client correctly present the file if you manually copy it over? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
deathkillspt Posted September 7, 2007 Author Share Posted September 7, 2007 (edited) Does the server generate the screenshot file to disk correctly, and that file is usable? Yes Does the file get transferred correctly to the client, and is usable from disk? No, I think it's failing here. Does the graphical code on the client correctly present the file if you manually copy it over? Actuallly it doesn't for some reason? But for instance if i do this: #include <A3LScreenCap.au3> _ScreenCap_Capture("Picture.jpg") $file = FileOpen("Picture.jpg",16) $fileread = FileRead($file) FileWrite("Picture2.jpg",$fileread) It works like a charm. But if i try to send $fileread over the connection and assemble it on the client side it doesnt work right, It just shows a whole bunch of numbers and it doesnt look anything like the graphical code of the picture taken on the server side. Edited September 7, 2007 by deathkillspt Link to comment Share on other sites More sharing options...
deathkillspt Posted September 7, 2007 Author Share Posted September 7, 2007 Thank you for explaining that a little better larry i have seen your scripts about this subject and i couldn't really make any sense of them. Now, i still dont know how to implement that into my script could you help me out a little? Link to comment Share on other sites More sharing options...
deathkillspt Posted September 7, 2007 Author Share Posted September 7, 2007 (edited) W00t W00t i thought about what larry said and i've finally got atleast something that works Client: expandcollapse popup#include <GUIConstants.au3> dim $sock #region GUI $frmmain = GUICreate("Send picture", 795, 577, 179, 116) $picdesktop = GUICtrlCreatePic("Capture.jpg", 8, 8, 777, 529, BitOR($SS_NOTIFY,$WS_GROUP)) $txtip = GUICtrlCreateInput("127.0.0.1", 520, 544, 121, 21) $txtport = GUICtrlCreateInput("1337", 648, 544, 57, 21) $btnconnect = GUICtrlCreateButton("Connect", 712, 544, 75, 25, 0) $txtsend = GUICtrlCreateInput("", 8, 544, 161, 21) $btnsend = GUICtrlCreateButton("Send", 176, 544, 75, 25, 0) $lblstatus = GUICtrlCreateLabel("Status: Disconnected", 312, 544, 156, 20) GUISetState(@SW_SHOW) #endregion While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Disconnect() Exit case $btnconnect Connect() case $btnsend SendToServer() EndSwitch Recive() WEnd func Recive();Recive routine $recv = TCPRecv($sock,100000000) if StringInStr($recv,"[start]") Then do $chars = TCPRecv($sock,1) FileWrite("Screenie.jpg",$chars) until $recv = "[end]" EndIf if $recv = "ac" Then GUICtrlSetData($lblstatus,"Status: Connected") EndIf EndFunc func SendToServer();Send routine TCPSend($sock,guictrlread($txtsend)) EndFunc func Connect();Connect routine TCPStartup() $sock = TCPConnect(guictrlread($txtip),guictrlread($txtport)) EndFunc func Disconnect();Disconnect routine TCPSend($sock,"disconnect") TCPCloseSocket($sock) TCPShutdown() EndFunc Server: expandcollapse popup#include <A3LScreenCap.au3> Global $Connectedsock = -1 Global $sock = -1 Local $ip = @IPAddress1 Local $port = 1337 TCPStartup() $sock = TCPListen($ip,$port);Wait for connection while 1 $recv = TCPRecv($connectedsock,100000000);Recive the data from the client if $recv = "disconnect" Then $connectedsock = -1 EndIf if StringInStr($recv,"run") Then $temp = StringSplit($recv,":") Run($temp[2]) EndIf if $recv = "desktop" Then _ScreenCap_Capture("pic.jpg") $file = FileOpen("pic.jpg",0) $size = FileGetSize("pic.jpg") TCPSend($connectedsock,"[start]") while $size > 0 $fileread = FileRead($file,1) TCPSend($connectedsock,$fileread) $size = $size - 1 WEnd TCPSend($connectedsock,"[end]") FileDelete("pic.jpg") EndIf if $connectedsock = -1 Then;Accept the connection $connectedsock = TCPAccept($sock) if $connectedsock <> - 1 Then TCPSend($connectedsock,"ac") EndIf EndIf WEnd Now time to refine it and make it faster. Edited September 7, 2007 by deathkillspt Link to comment Share on other sites More sharing options...
Hidix17 Posted December 9, 2014 Share Posted December 9, 2014 (edited) If you want to "read" image, you should do something like this: #include <A3LScreenCap.au3> #include <File.au3> _ScreenCap_Capture("Picture.jpg") If FileExists("Picture.txt") then FileDelete("Picture.txt") Endif FileCopy("Picture.jpg","Picture.txt") $Image = FileRead("Picture.txt") Edited December 9, 2014 by Hidix17 Link to comment Share on other sites More sharing options...
BrewManNH Posted December 9, 2014 Share Posted December 9, 2014 Pretty sure that whoever was needing that information won't need it 7 years later. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
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