Just remembered this one and tried to make it work without AutoItObject, requires Beta to run properly .
#include <IE.au3>
#include <WinAPI.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>
; Runs fine with Beta 3.3.9.5+
If Int(StringReplace(@AutoItVersion, ".", "")) <= 3381 Then
MsgBox(0, "Exit", "Requires AutoIt version > 3.3.8.1, try with Beta")
Exit
EndIf
Global $dtagIUnknown = "QueryInterface hresult(ptr;ptr*);" & _
"AddRef dword();" & _
"Release dword();"
Global Const $gh_AU3Obj_ole32dll = DllOpen("ole32.dll")
WebCaptureTest("http://funk.eu", "Test1.png")
Func WebCaptureTest($Url, $ImageName)
Local $hBmp = WebCapture($Url, 1280)
_ScreenCapture_SaveImage($ImageName, $hBmp, True)
EndFunc ;==>WebCaptureTest
Func WebCapture($Url, $WebWidth = 1024)
Local Const $DVASPECT_CONTENT = 1
Local $tIID_IViewObject2 = _CLSIDFromString("{00000127-0000-0000-C000-000000000046}")
Local $dtagIViewObject2 = $dtagIUnknown & "Draw hresult(dword;long;ptr;ptr;dword;dword;ptr;ptr;int;dword);"
Local $oIE = ObjCreate("Shell.Explorer.2")
GUICreate("", $WebWidth, 768, -1, -1)
GUICtrlCreateObj($oIE, 0, 0, $WebWidth, 768)
_IELoadWaitTimeout(20000) ; 20 sec
_IENavigate($oIE, $Url)
_IELoadWait($oIE)
Local $oDocument = $oIE.document
Local $oBody = $oIE.document.body
Local $oHtml = $oIE.document.documentElement
$oBody.scroll = "no"
$oBody.style.borderStyle = "none"
$oHtml.style.overflow = 'hidden'
$oBody.style.overflow = 'hidden'
Local $oIViewObject2 = ObjCreateInterface($oDocument, "{00000127-0000-0000-C000-000000000046}", "Draw hresult(dword;long;ptr;ptr;dword;dword;ptr;ptr;int;dword);")
If @error Then Return SetError(1, 0, 0)
Local $BodyWidth = $oBody.scrollWidth
Local $BodyHeight = $oBody.scrollHeight
Local $RootWidth = $oHtml.scrollWidth
Local $RootHeight = $oHtml.scrollHeight
Local $Width = $BodyWidth
Local $Height = $RootHeight
If $BodyHeight > $Height Then $Height = $BodyHeight
$oIE.width = $Width
$oIE.height = $Height
Local $hDC = _WinAPI_GetDC(0)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBmp = _WinAPI_CreateCompatibleBitmap($hDC, $Width, $Height)
_WinAPI_SelectObject($hMemDC, $hBmp)
Local $sRECT = DllStructCreate($tagRECT)
DllStructSetData($sRECT, "Top", 0)
DllStructSetData($sRECT, "Left", 0)
DllStructSetData($sRECT, "Right", $Width)
DllStructSetData($sRECT, "Bottom", $Height)
$oIViewObject2.Draw($DVASPECT_CONTENT, -1, 0, 0, Number($hDC), Number($hMemDC), Number(DllStructGetPtr($sRECT)), 0, 0, 0)
_WinAPI_DeleteDC($hMemDC)
_WinAPI_ReleaseDC(0, $hDC)
Return $hBmp
EndFunc ;==>WebCapture
Func _CLSIDFromString($sString)
Local $tCLSID = DllStructCreate("dword;word;word;byte[8]")
Local $aResult = DllCall($gh_AU3Obj_ole32dll, 'long', 'CLSIDFromString', 'wstr', $sString, 'ptr', DllStructGetPtr($tCLSID))
If @error Then Return SetError(1, @error, 0)
If $aResult[0] <> 0 Then Return SetError(2, $aResult[0], 0)
Return $tCLSID
EndFunc ;==>_CLSIDFromString