#include <GDIPlus.au3>
#include <Clipboard.au3>
#include <WinAPIDiag.au3>
# example
#include <IE.au3>
;~ Local $oIE = _IECreate('http://images.yandex.by/#!/yandsearch?text=обои&uinfo=ww-1118-wh-742-fw-893-fh-536-pd-1', 1, 1, 1, 0)
Local $oIE = _IECreate('http://images.yandex.by/#!/yandsearch?text=обои&uinfo=ww-1118-wh-742-fw-0-fh-536-pd-1', 1, 1, 1, 0)
Sleep(5000)
Local $oImgs = _IETagNameGetCollection($oIE, 'img')
Local $bData, $hFile,$ext = 'png'
For $oImg In $oImgs
$bData = _IEImageGetBinary_2($oImg)
$hFile = FileOpen('images/' & Random() & '.' & $ext, 2 + 8 + 16)
FileWrite($hFile, $bData)
FileClose($hFile)
;~ ExitLoop
Next
Func _IEImageGetBinary_2($oImg)
If Not IsObj($oImg) Then Return SetError(1, 0, 0)
Local $oCtlRange = $oImg.document.body.createControlRange()
If Not IsObj($oCtlRange) Then Return SetError(3, 1, 0)
$oCtlRange.addElement($oImg)
$oCtlRange.execCommand('Copy', False)
_ClipBoard_Open(0)
Local $hBitmap = _ClipBoard_GetDataEx($CF_BITMAP)
Local $hBITMAPINFO = _ClipBoard_GetDataEx($CF_DIB)
_ClipBoard_Close()
ConsoleWrite($hBitmap & @LF)
Local Const $tagBITMAPINFOHEADER_Beta = "dword biSize;long biWidth;long biHeight;word biPlanes;word biBitCount;" & _
"dword biCompression;dword biSizeImage;long biXPelsPerMeter;long biYPelsPerMeter;dword biClrUsed;dword biClrImportant;"
ConsoleWrite($oImg.src & @LF)
_WinAPI_DisplayStruct ( $hBITMAPINFO ,$tagBITMAPINFOHEADER_Beta )
_GDIPlus_Startup()
Local $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
_WinAPI_DeleteObject($hBitmap)
;Нужно узнать формат картинки???, по умолчанию png
Local $sImgCLSID
Local $format = _GDIPlus_ImageGetRawFormat ( $hImage )
Local $ext = 'png'
Local $aret = StringRegExp($oImg.src,'\.([^.\\/:*?"<>|\r\n]+)$',1)
If IsArray($aret) Then $ext = $aret[0]
Local $sImgCLSID = _GDIPlus_EncodersGetCLSID($ext)
ConsoleWrite($ext & @LF)
ConsoleWrite($format[0] & @LF)
ConsoleWrite($format[1] & @LF)
ConsoleWrite('=========' & @LF)
Local $tGUID = _WinAPI_GUIDFromString($sImgCLSID)
Local $pEncoder = DllStructGetPtr($tGUID)
Local $pStream = _WinAPI_CreateStreamOnHGlobal()
_GDIPlus_ImageSaveToStream($hImage, $pStream, $pEncoder)
_GDIPlus_ImageDispose($hImage)
Local $pData = _WinAPI_GetHGlobalFromStream($pStream)
Local $pMemory = _MemGlobalLock($pData)
Local $iSize = _MemGlobalSize($pData)
Local $bytes = DllStructCreate('byte[' & $iSize & ']', $pMemory)
Local $binary = DllStructGetData($bytes, 1)
_MemGlobalUnlock($pMemory)
_WinAPI_ReleaseStream($pStream)
_GDIPlus_Shutdown()
Return SetError(0, 0, $binary)
EndFunc ;==>_IEImageGetBinary_2