If you want to spy your own laptop while you are not using it, by getting screen shots then this would be really. If you want to do it only by Autoit, problem is that you can't upload some files using it. So the other method I found was to convert the image to text (Pixel values) and then mail the text. Then you can easily decode the text into image by using similar functions.
This is how the mail looked like..
I just combined the previous gmail application thing with the functions given here. So here's how to do it.
;Libraries.....
#include <WinAPI.au3>
#include <IE.au3>
#include <GUIConstants.au3>
#include <EditConstants.au3>
#include <GDIPlus.au3>
#include <Array.au3>
#include <File.au3>
#include <ScreenCapture.au3>
;Variables.....
Global $sUser = "manji3691@gmail.com", $sPwd = "", $sTo = "manji369@gmail.com", $sSubject = "screen capture", $sBody
Global $sFilePath = "C:\Manji\img.txt"
Opt("MustDeclareVars", 1)
_ScreenCapture_Capture("C:\Manji\11.jpg")
_GDIPlus_Startup()
Dim $pixelarray
Local $file_in = "C:\Manji\11.jpg"
Local $file_out = "C:\Manji\1.jpg"
_FileImageToArray($file_in, $pixelarray)
_FileWriteFromArray($sFilePath, $pixelarray)
_GDIPlus_Shutdown()
Global $chars = FileRead($sFilePath, -1)
$sBody = $chars
;Navigating to Internet Explorer to login and send email..
;You can set the 3rd argument to 0 from 1 if you donot wish to see the mail being sent...
;Like opening of browser.. .
Global $oIE, $oForm, $oUser, $oPwd, $oChkbx, $oButton
$oIE = _IECreate("https://accounts.google.com/ServiceLogin?service=mail&?ui=html&zy=h")
;Waiting till it loads
_IELoadWait($oIE)
;Getting the form fields
$oForm = _IEFormGetObjByName($oIE, "gaia_loginform")
$oUser = _IEFormElementGetObjByName($oForm, "Email")
$oPwd = _IEFormElementGetObjByName($oForm, "Passwd")
$oChkbx = _IEFormElementGetObjByName($oForm, "PersistentCookie")
$oButton = _IEFormElementGetObjByName($oForm, "signIn")
;Setting the username, pwd ....
_IEFormElementSetValue($oUser, $sUser)
_IEFormElementSetValue($oPwd, $sPwd)
_IEAction($oChkbx, "click")
_IEAction($oButton, "click")
_IELoadWait($oIE)
;Navigating to "compose mail"
_IENavigate($oIE,"https://mail.google.com/mail/h/?&v=b&pv=tl&cs=b")
_IELoadWait($oIE)
Global $oForm1, $oTo, $oSubject, $oBody, $oSendButton
;Getting the fields to fill in for sending the mail
$oForm1 = _IEFormGetObjByName($oIE, "f")
$oTo = _IEFormElementGetObjByname($oForm1, "to")
$oSubject = _IEFormElementGetObjByname($oForm1, "subject")
$oBody = _IEFormElementGetObjByname($oForm1, "body")
$oSendButton = _IEFormElementGetObjByname($oForm1, "nvp_bu_send")
;Entering the details of mail to be sent
_IEFormElementSetValue($oTo, $sTo)
_IEFormElementSetValue($oSubject, $sSubject)
_IEFormElementSetValue($oBody, $sBody)
_IEAction($oSendButton, "click")
_IELoadWait($oIE)
;Quit IE
_IEQuit($oIE)
; code by Malkey: thanks man!
Func _FileImageToArray($filename, ByRef $aArray)
Local $Reslt, $stride, $format, $Scan0, $iW, $iH, $hImage
Local $v_Buffer, $width, $height
Local $i, $j
$hImage = _GDIPlus_ImageLoadFromFile($filename)
$iW = _GDIPlus_ImageGetWidth($hImage)
$iH = _GDIPlus_ImageGetHeight($hImage)
$Reslt = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW, $iH, $GDIP_ILMREAD, $GDIP_PXF32ARGB)
;Get the returned values of _GDIPlus_BitmapLockBits ()
$width = DllStructGetData($Reslt, "width")
$height = DllStructGetData($Reslt, "height")
$stride = DllStructGetData($Reslt, "stride")
$format = DllStructGetData($Reslt, "format")
$Scan0 = DllStructGetData($Reslt, "Scan0")
Dim $aArray[$width][$height]
For $i = 0 To $iW - 1
For $j = 0 To $iH - 1
$v_Buffer = DllStructCreate("dword", $Scan0 + ($j * $stride) + ($i * 4))
$aArray[$i][$j] = Hex(DllStructGetData($v_Buffer, 1), 8)
Next
Next
_GDIPlus_BitmapUnlockBits($hImage, $Reslt)
_GDIPlus_ImageDispose($hImage)
Return
EndFunc ;==>_FileImageToArray
; code by Malkey: thanks again ;)
Func _FileArrayToImage($filename, $aArray)
Local $iW = UBound($aArray, 1), $iH = UBound($aArray, 2), $sResult = ""
Local $hBMP, $hImage1, $Reslt, $width, $height, $stride, $format, $Scan0
Local $sResult, $v_BufferA
Local $i, $j
$hBMP = _WinAPI_CreateBitmap($iW, $iH, 1, 32)
$hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
$Reslt = _GDIPlus_BitmapLockBits($hImage1, 0, 0, $iW, $iH, $GDIP_ILMWRITE, $GDIP_PXF32ARGB)
;Get the returned values of _GDIPlus_BitmapLockBits ()
$width = DllStructGetData($Reslt, "width")
$height = DllStructGetData($Reslt, "height")
$stride = DllStructGetData($Reslt, "stride")
$format = DllStructGetData($Reslt, "format")
$Scan0 = DllStructGetData($Reslt, "Scan0")
$v_BufferA = DllStructCreate("byte[" & $height * $width * 4 & "]", $Scan0)
;$AllPixels = DllStructGetData($v_BufferA, 1)
For $j = 0 To $height - 1
For $i = 0 To $width - 1
$sResult &= StringRegExpReplace($aArray[$i][$j],"(..)(..)(..)(..)","\4\3\2\1")
Next
Next
DllStructSetData($v_BufferA, 1, "0x" & StringStripWS($sResult, 8))
_GDIPlus_BitmapUnlockBits($hImage1, $Reslt)
_GDIPlus_ImageSaveToFile($hImage1, $filename)
_GDIPlus_ImageDispose($hImage1)
_WinAPI_DeleteObject($hBMP)
Return
EndFunc ;==>_FileArrayToImage
;Quit program
Exit
Also get the source here.
0 comments:
Post a Comment