Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

ScreenShot ready to send via TCPSend


  • Please log in to reply
17 replies to this topic

#1 crash748

crash748

    Seeker

  • Active Members
  • 43 posts

Posted 30 August 2007 - 07:18 AM

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:
AutoIt         
#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   ;==>SendFuncƒo݊÷ Ù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 by crash748, 11 September 2007 - 04:41 PM.








#2 andres555

andres555

    Seeker

  • Active Members
  • 22 posts

Posted 30 August 2007 - 12:36 PM

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;#entry392656

 Func _SockRecv($iSocket)     Local $sData = Binary("")     While $sData = ""         $sData = TCPRecv($iSocket, 3000)     WEnd     $sData=Binary($sData)     Return $sData EndFunc;==>_SockRecv

Edited by andres555, 30 August 2007 - 12:39 PM.


#3 crash748

crash748

    Seeker

  • Active Members
  • 43 posts

Posted 30 August 2007 - 03:22 PM

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 by crash748, 11 September 2007 - 04:43 PM.


#4 andres555

andres555

    Seeker

  • Active Members
  • 22 posts

Posted 31 August 2007 - 02:18 AM

Plain Text         
#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 by andres555, 31 August 2007 - 02:19 AM.


#5 crash748

crash748

    Seeker

  • Active Members
  • 43 posts

Posted 01 September 2007 - 04:42 AM

Plain Text         
#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.

#6 CoDEmanX

CoDEmanX

    Seeker

  • Active Members
  • 24 posts

Posted 10 September 2007 - 07:11 PM

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)?

#7 crash748

crash748

    Seeker

  • Active Members
  • 43 posts

Posted 10 September 2007 - 11:10 PM

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 by crash748, 21 September 2007 - 05:19 PM.


#8 crash748

crash748

    Seeker

  • Active Members
  • 43 posts

Posted 10 September 2007 - 11:48 PM

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?

#9 CoDEmanX

CoDEmanX

    Seeker

  • Active Members
  • 24 posts

Posted 11 September 2007 - 11:29 PM

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 by CoDEmanX, 11 September 2007 - 11:47 PM.


#10 crash748

crash748

    Seeker

  • Active Members
  • 43 posts

Posted 12 September 2007 - 06:19 AM

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
AutoIt         
#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!

#11 CoDEmanX

CoDEmanX

    Seeker

  • Active Members
  • 24 posts

Posted 13 September 2007 - 12:03 PM

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 by CoDEmanX, 13 September 2007 - 01:06 PM.


#12 CoDEmanX

CoDEmanX

    Seeker

  • Active Members
  • 24 posts

Posted 15 September 2007 - 01:42 AM

VB-Code using IStream...

Attached: In Memory Image Compression C++ Sourcecode + AutoIt-Helpfile COM (PDF)

Attached Files



#13 crash748

crash748

    Seeker

  • Active Members
  • 43 posts

Posted 15 September 2007 - 07:41 AM

VB-Code using IStream...

Attached: In Memory Image Compression C++ Sourcecode + AutoIt-Helpfile COM (PDF)

Thank you very much!! :)

#14 CoDEmanX

CoDEmanX

    Seeker

  • Active Members
  • 24 posts

Posted 15 September 2007 - 08:43 AM

please let me/us know if you got it working!

i/we might support you hopefully

#15 crash748

crash748

    Seeker

  • Active Members
  • 43 posts

Posted 15 September 2007 - 02:05 PM

Sure, it will be a pleasure! :)

#16 CoDEmanX

CoDEmanX

    Seeker

  • Active Members
  • 24 posts

Posted 22 September 2007 - 01:31 AM

IStream (MSDN): http://msdn2.microsoft.com/en-us/library/aa380034.aspx

CreateStreamOnHGlobal (MSDN): http://msdn2.microsoft.com/en-us/library/aa378980.aspx


i don't have an idea how to use it...

Edited by CoDEmanX, 22 September 2007 - 01:35 AM.


#17 CoDEmanX

CoDEmanX

    Seeker

  • Active Members
  • 24 posts

Posted 04 October 2007 - 04:08 PM

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­¢Ø^²ÚÞjd­jÛ¬I«ÞJÖ­º



Plain Text         
// 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?

#18 CoDEmanX

CoDEmanX

    Seeker

  • Active Members
  • 24 posts

Posted 03 November 2007 - 01:59 AM

thread is dead <_<


How to return a IStream COM object?

Dynamic string buffer allocation using IStream

Edited by CoDEmanX, 03 November 2007 - 02:06 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users