Example in still contained some AutoItObject leftovers, here's a more cleaned up version. #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
_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 $oIE = ObjCreate("Shell.Explorer.2")
Local $hGUI = GUICreate("", $WebWidth, 768, -1, -1)
Local $cObj = 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)
Local Const $DVASPECT_CONTENT = 1
$oIViewObject2.Draw($DVASPECT_CONTENT, -1, 0, 0, Number($hDC), Number($hMemDC), Number(DllStructGetPtr($sRECT)), 0, 0, 0)
_WinAPI_DeleteDC($hMemDC)
_WinAPI_ReleaseDC(0, $hDC)
GUICtrlDelete($cObj)
GUIDelete($hGUI)
$oIViewObject2 = 0
$oIE = 0
Return $hBmp
EndFunc ;==>_WebCapture