crash748 Posted August 30, 2007 Share Posted August 30, 2007 (edited) I am making a script to take screenshot on ComputerA then send it to ComputerB but i don't want the screenshot to be write on the HardDisk each time. An example of my current script: expandcollapse popup#include <A3LScreenCap.au3> Global $ControlledComputerIP = "192.168.0.11" Global $ControlledComputerPort = 65432 Global $Socket Global $Connected = "NO" While 1 If $Connected = "YES" Then ;Take Screenshot to ScreenShot.jpg _ScreenCap_SetJPGQuality (50) _ScreenCap_Capture ("ScreenShot.jpg") ;Set $DATA with the content of ScreenShot.jpg $File = FileOpen("ScreenShot.jpg", 0 + 16); 0=read + 16=binary $DATA = "(START)" & FileRead($File) & "(END)" FileClose($File) ;Send the ScreenShot to the server SendFunc($DATA) Else ServerNegociation() EndIf Sleep(1000) WEnd Func ServerNegociation() ;~ ; Start The TCP Services ;~ ;============================================== ;~ TCPStartup() ;~ ; Connect to a Listening "SOCKET" ;~ ;============================================== ;~ $Socket = TCPConnect($ControlledComputerIP, $ControlledComputerPort) ;~ If $Socket = -1 Then ;~ TCPShutdown() ;~ $Connected = "NO" ;~ Else $Connected = "YES" ;~ EndIf EndFunc ;==>ServerNegociation Func SendFunc($DATA) ;~ ;Send DATA to the server ;~ TCPSend($Socket, $DATA) ;~ If @error Then ;~ TCPShutdown() ;~ $Connected = "NO" ;~ $Socket = -1 ;~ EndIf EndFunc ;==>SendFuncoÝ÷ Ù8^IÊÞzt¡¢Ø¬Â¸zíáö§æ~º&¶Â¢jnµêÀmçèèq©ÛzǧvÚ¢jnµêÁßr0j{[y¦åzÚ¢Ê&zØb bëaȧ¶)^.)jëh×6#include <A3LScreenCap.au3> Global $ControlledComputerIP = "192.168.0.11" Global $ControlledComputerPort = 65432 Global $Socket Global $Connected = "NO" Global $hBitmap While 1 If $Connected = "YES" Then ; ;Take Screenshot _ScreenCap_SetJPGQuality (50) $hBitmap = _ScreenCap_Capture () ;Set $DATA with the content of $hBitmap $DATA = "(START)" & $hBitmap & "(END)" ;Send the ScreenShot to the server SendFunc($DATA) ; Else ServerNegociation() EndIf Sleep(1000) WEnd Func ServerNegociation() ;~ ; Start The TCP Services ;~ ;============================================== ;~ TCPStartup() ;~ ; Connect to a Listening "SOCKET" ;~ ;============================================== ;~ $Socket = TCPConnect($ControlledComputerIP, $ControlledComputerPort) ;~ If $Socket = -1 Then ;~ TCPShutdown() ;~ $Connected = "NO" ;~ Else $Connected = "YES" ;~ EndIf EndFunc ;==>ServerNegociation Func SendFunc($DATA) ;~ ;Send DATA to the server ;~ TCPSend($Socket, $DATA) ;~ If @error Then ;~ TCPShutdown() ;~ $Connected = "NO" ;~ $Socket = -1 ;~ EndIf EndFunc ;==>SendFunc What can i do with $hBitmap to get the binary string of the screenshot? Currently $hBitmap = 0x240508E0 I really need help with the manipulation HBITMAP handle to get the result I want. Edited September 11, 2007 by crash748 Link to comment Share on other sites More sharing options...
andres555 Posted August 30, 2007 Share Posted August 30, 2007 (edited) hi, i dont understand u very well, but u can read or write a file in a binary form using $file = FileOpen($scre..., 16)make a file .jpg on the variable $hBitmap and later open with FileOpen....or just put $hbitmap=binary(_ScreenCap_Capture ())for recive u have to put the next lines...remember u can send only a max of 2048bytes....if u want more help go to my post file transfer Tcp/ip http://www.autoitscript.com/forum/index.ph...mp;#entry392656Func _SockRecv($iSocket) Local $sData = Binary("") While $sData = "" $sData = TCPRecv($iSocket, 3000) WEnd $sData=Binary($sData) Return $sData EndFunc;==>_SockRecv Edited August 30, 2007 by andres555 Link to comment Share on other sites More sharing options...
crash748 Posted August 30, 2007 Author Share Posted August 30, 2007 (edited) I have try $hbitmap=binary(_ScreenCap_Capture ()) but i don't get the needed result.$hbitmap = 0x49080582 If i send this to the server, the server don't receive the jpeg but only the BitMap handle. I want get the same result as $DATA = FileRead($File) but without the need to save and read the jpeg every time.#include <A3LScreenCap.au3> $hBitmap = _ScreenCap_Capture () _ScreenCap_SaveImage ("ScreenShot.jpg", $hBitmap) $File = FileOpen("ScreenShot.jpg", 16) $DATA = FileRead($File) FileClose($File) Edited September 11, 2007 by crash748 Link to comment Share on other sites More sharing options...
andres555 Posted August 31, 2007 Share Posted August 31, 2007 (edited) #include <GUIConstants.au3> #include <Inet.au3> Local $IP = InputBox( "IP Address", "Enter your IP address", @IPAddress1 ) Local $snapfile = @ScriptDir & "\crt411.exe"; file to send Local $file = FileOpen($snapfile, 16) Local $output = FileRead($file, FileGetSize($snapfile)) FileClose($file) Local $bitessss=2000 Local $ipreceptora=_GetIP() ;public ip of client ; slicing file ******************************************************* if BinaryLen($output)>$bitessss Then $entero=Int(BinaryLen($output)/$bitessss) Dim $data[$entero+1] Local $c=1 Local $i=0 $Form1_2 = GUICreate("Utilidades1", 261, 298, 377, 242) $Label22 = GUICtrlCreateLabel("", 56, 184, 136, 17) GUISetState(@SW_SHOW) While $i<=$entero-1 $nMsg = GUIGetMsg() GUICtrlSetData ( $Label22, $i&" de "&$entero-1 ) $data[$i]=BinaryMid( $output,$c , $bitessss ) $c=$c+$bitessss $i=$i+1 WEnd $data[$i]=BinaryMid( $output,$c) Else $entero=0 Dim $data[1] $data[0]=$output EndIf later u have to send thats packet to the other server look my post i do the same that u want to do the only diferent i read anyfile on my script Edited August 31, 2007 by andres555 Link to comment Share on other sites More sharing options...
crash748 Posted September 1, 2007 Author Share Posted September 1, 2007 #include <GUIConstants.au3> #include <Inet.au3> Local $IP = InputBox( "IP Address", "Enter your IP address", @IPAddress1 ) Local $snapfile = @ScriptDir & "\crt411.exe"; file to send Local $file = FileOpen($snapfile, 16) Local $output = FileRead($file, FileGetSize($snapfile)) FileClose($file) Local $bitessss=2000 Local $ipreceptora=_GetIP();public ip of client ; slicing file ******************************************************* if BinaryLen($output)>$bitessss Then $entero=Int(BinaryLen($output)/$bitessss) Dim $data[$entero+1] Local $c=1 Local $i=0 $Form1_2 = GUICreate("Utilidades1", 261, 298, 377, 242) $Label22 = GUICtrlCreateLabel("", 56, 184, 136, 17) GUISetState(@SW_SHOW) While $i<=$entero-1 $nMsg = GUIGetMsg() GUICtrlSetData ( $Label22, $i&" de "&$entero-1 ) $data[$i]=BinaryMid( $output,$c , $bitessss ) $c=$c+$bitessss $i=$i+1 WEnd $data[$i]=BinaryMid( $output,$c) Else $entero=0 Dim $data[1] $data[0]=$output EndIf later u have to send thats packet to the other server look my post i do the same that u want to do the only diferent i read anyfile on my script It's certain but for now i think i will look at the PaulIA work to learn how I can do my Screen Capture manipulation. Link to comment Share on other sites More sharing options...
CoDEmanX Posted September 10, 2007 Share Posted September 10, 2007 I have try $hbitmap=binary(_ScreenCap_Capture ()) but i don't get the needed result. $hbitmap = 0x49080582 If i send this to the server, the server don't receive the jpeg but only the BitMap handle. I want get the same result as $DATA = FileRead($File) but without the need to save and read the jpeg every time. $hBitmap = _ScreenCap_Capture () _ScreenCap_SaveImage ("ScreenShot.jpg", $hBitmap) $File = FileOpen("ScreenShot.jpg", 16) $DATA = FileRead($File) FileClose($File) he wants to send images from screen (screenshots) to another computer WITHOUT screencapturing to harddisk. is it possible to send data from a variable (ram) to another computer (without any file access)? btw: how can i adjust the jpeg compression quality using GDI+ (auto3lib)? Link to comment Share on other sites More sharing options...
crash748 Posted September 10, 2007 Author Share Posted September 10, 2007 (edited) btw: how can i adjust the jpeg compression quality using GDI+ (auto3lib)?I do it this way...The good code was in the post #10 of this topic Edited September 21, 2007 by crash748 Link to comment Share on other sites More sharing options...
crash748 Posted September 10, 2007 Author Share Posted September 10, 2007 he wants to send images from screen (screenshots) to another computer WITHOUT screencapturing to harddisk. is it possible to send data from a variable (ram) to another computer (without any file access)?Did anybody with some experience can say if it was possible or not? If it was possible to write it in a file why it should not be possible to put it in a variable? Link to comment Share on other sites More sharing options...
CoDEmanX Posted September 11, 2007 Share Posted September 11, 2007 (edited) it is possible, dont know if possible with autoit... some ideas (what i remember): - pipes for redirecting file output? - reading memory (ram, at address where the image is saved) - autoit script-internal conversion to image format (bmp/jpg/png/...) - "take over" of the data stream (possible in "real" programming languages like c++ or .net but very difficult) http://msdn.microsoft.com/library/default....usreference.asp http://msdn2.microsoft.com/en-us/library/ms535410.aspx @crash748: doesn't work and doesn't use gdi+ as far as i can see... should be something like this: ; Set up parameters for compression quality $tData = DllStructCreate("int Data") DllStructSetData($tData, "Data", $GDIP_EPGQUALITY) $tParams = _GDIP_ParamInit(1) _GDIP_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, DllStructGetPtr($tData, "Data")) _GDIP_ImageSaveToFileEx ($aSlice[$iI], "C:\A3LSlice" & $iI & ".jpg", $sCLSID, $tParams) Edited September 11, 2007 by CoDEmanX Link to comment Share on other sites More sharing options...
crash748 Posted September 12, 2007 Author Share Posted September 12, 2007 it is possible, dont know if possible with autoit... some ideas (what i remember): - pipes for redirecting file output? - reading memory (ram, at address where the image is saved) - autoit script-internal conversion to image format (bmp/jpg/png/...) - "take over" of the data stream (possible in "real" programming languages like c++ or .net but very difficult) http://msdn.microsoft.com/library/default....usreference.asp http://msdn2.microsoft.com/en-us/library/ms535410.aspx @crash748: doesn't work and doesn't use gdi+ as far as i can see... should be something like this:Your right i make a mistake there the code to change the quality of the .jpg #include <A3LScreenCap.au3> #include <A3LGDIPlus.au3> Local $sCLSID, $tData, $hImage, $pParams, $tParams Global $JPGQuality = 75 ;1-100 ; Load image $hBitmap = _ScreenCap_Capture ("") ; Start GDI _GDIP_StartUp () ; Convert my screenshot (bitmap handle) to (Bitmap object) $hImage = _GDIP_BitmapCreateFromHBITMAP ($hBitmap) ; Jpeg Setting $sCLSID = _GDIP_EncodersGetCLSID ("JPG") $tParams = _GDIP_ParamInit (1) $tData = DllStructCreate("int Quality") DllStructSetData($tData, "Quality", $JPGQuality) _GDIP_ParamAdd ($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, DllStructGetPtr($tData)) If IsDllStruct($tParams) Then $pParams = DllStructGetPtr($tParams) ; Save the image _GDIP_ImageSaveToFileEx ($hImage, "Image.jpg", $sCLSID, $pParams) ; Clean Up _GDIP_ImageDispose ($hImage) _API_DeleteObject ($hBitmap) ; Stop GDI _GDIP_ShutDown () Thanks for your tip! Maybe i will find something! Link to comment Share on other sites More sharing options...
CoDEmanX Posted September 13, 2007 Share Posted September 13, 2007 (edited) check this out!In Memory Image Compression C++ (VC7.1 / VC7 / VC6)we have to ask the author for a dll, cause i assume we can't do the same using AutoIt...//edit: asked him ("Memory Image Compression DLL?")I am not familiar with AutoIt-Scripting, but if the script can utilize COM, then it should be able to utilize IStream object. I am not really sure that rewriting the application to be a DLL would solve your problem. Possibly, the best solution would be to provide COM capabilities to the scripting language.Sorry I could not be of more help! Edited September 13, 2007 by CoDEmanX Link to comment Share on other sites More sharing options...
CoDEmanX Posted September 15, 2007 Share Posted September 15, 2007 VB-Code using IStream...Attached: In Memory Image Compression C++ Sourcecode + AutoIt-Helpfile COM (PDF)MemImage.zipAutoIt_COM.pdf Link to comment Share on other sites More sharing options...
crash748 Posted September 15, 2007 Author Share Posted September 15, 2007 VB-Code using IStream...Attached: In Memory Image Compression C++ Sourcecode + AutoIt-Helpfile COM (PDF)Thank you very much!! Link to comment Share on other sites More sharing options...
CoDEmanX Posted September 15, 2007 Share Posted September 15, 2007 please let me/us know if you got it working! i/we might support you hopefully Link to comment Share on other sites More sharing options...
crash748 Posted September 15, 2007 Author Share Posted September 15, 2007 Sure, it will be a pleasure! Link to comment Share on other sites More sharing options...
CoDEmanX Posted September 22, 2007 Share Posted September 22, 2007 (edited) IStream (MSDN): http://msdn2.microsoft.com/en-us/library/aa380034.aspxCreateStreamOnHGlobal (MSDN): http://msdn2.microsoft.com/en-us/library/aa378980.aspxi don't have an idea how to use it... Edited September 22, 2007 by CoDEmanX Link to comment Share on other sites More sharing options...
CoDEmanX Posted October 4, 2007 Share Posted October 4, 2007 ok, i have still no idea how to manage but i let my mind wander:// load image Image image(L"Nice.bmp");we need an image:; Initialize GDI+ library _GDIP_StartUp() ; Capture screen $hBitmap = _ScreenCap_Capture("C:\A3LImage.bmp") ; Load image and emboss text $hImage = _GDIP_ImageLoadFromFile("C:\A3LImage.bmp")oÝ÷ ÙÊ{ÿÂæzËky©°Øt²,Þ!+ky©©!+ky©oÝ÷ ÙÊ{ÿÒj÷è¦j¢Ø^²ÚÞjdjÛ¬I«ÞJÖºexpandcollapse popup// get the size of the stream ULARGE_INTEGER ulnSize; LARGE_INTEGER lnOffset; lnOffset.QuadPart = 0; if(pIStream->Seek(lnOffset, STREAM_SEEK_END, &ulnSize) != S_OK) { pIStream->Release(); AfxMessageBox(_T("Failed to get the size of the stream!")); return; } // now move the pointer to the beginning of the file if(pIStream->Seek(lnOffset, STREAM_SEEK_SET, NULL) != S_OK) { pIStream->Release(); AfxMessageBox(_T("Failed to move the file pointer to " "the beginning of the stream!")); return; } // here you can do what ever you want /* 1. You can use global memory HGLOBAL hg; if(GetHGlobalFromStream(pIStream, &hg) = S_OK) ... use hg for something 2. Copy it into some other buffer char *pBuff = new char[ulnSize.QuadPart]; // Read the stream directly into the buffer ULONG ulBytesRead; if(pIStream->Read(pBuff, ulnSize.QuadPart, &ulBytesRead) != S_OK) { pIStream->Release(); return; } */ // I am going to save it to the file just so we can // load the jpg to a gfx program CFile fFile; if(fFile.Open(_T("test.jpg"), CFile::modeCreate | CFile::modeWrite)) { char *pBuff = new char[ulnSize.QuadPart]; // Read the stream directly into the buffer ULONG ulBytesRead; if(pIStream->Read(pBuff, ulnSize.QuadPart, &ulBytesRead) != S_OK) { pIStream->Release(); delete pBuff; return; } fFile.Write(pBuff, ulBytesRead); fFile.Close(); delete pBuff; } else AfxMessageBox(_T("Failed to save data to the disk!")); // Free memory used by the stream pIStream->Release();no idea at all... AutoIt Lib 3 has some memory functions, eg. _Mem_GlobalAlloc($iBytes[, $iFlags]) or _Mem_CtrlRead(ByRef $tMemMap, $pSrce, $pDest, $iSize).anybody who can help us? Link to comment Share on other sites More sharing options...
CoDEmanX Posted November 3, 2007 Share Posted November 3, 2007 (edited) thread is dead How to return a IStream COM object?Dynamic string buffer allocation using IStream Edited November 3, 2007 by CoDEmanX 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