Код:
#include <IE.au3>
#include <WinAPI.au3>
#Include <ScreenCapture.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$oIE = _IECreateEmbedded()
$hGui = GUICreate("", 1000, 500,-1, -1)
GUICtrlCreateObj($oIE, 0, 0, 990, 490)
_IENavigate($oIE, 'http://www.mail.ru')
GUISetState() ;Окно открыто
_ScreenCapture_CaptureBackgrWnd(@DesktopDir & "\Окно_не_скрыто.jpg", $hGui) ;Делаю скриншот и сохраняю на рабочий стол "Окно_не_скрыто.jpg"
GUISetState(@SW_HIDE) ;Скрываю окно
_ScreenCapture_CaptureBackgrWnd(@DesktopDir & "\Окно_скрыто.jpg", $hGui) ;Делаю скриншот и сохраняю на рабочий стол "Окно_скрыто.jpg"
GUISetState()
While GUIGetMsg() <> $GUI_EVENT_CLOSE
WEnd
Func _ScreenCapture_CaptureBackgrWnd($sFileName, $hWnd, $iWidth = -1, $iHeight = -1)
Local $iOpt_WWD, $hActive, $aPos, $iH, $iW, $hDDC, $hCDC, $hBMP
If Not IsHWnd($hWnd) Then Return SetError(1, 0, 0)
If Not BitAND(WinGetState($hWnd), 2) Then
$iOpt_WWD = Opt("WinWaitDelay", 0)
$hActive = WinGetHandle("[ACTIVE]")
$aPos = WinGetPos($hWnd)
WinMove($hWnd, "", -1500, -1500)
WinSetState($hWnd, "", @SW_SHOW)
WinActivate($hActive)
WinWaitActive($hActive)
Opt("WinWaitDelay", $iOpt_WWD)
ElseIf BitAND(WinGetState($hWnd), 16) Then
$iOpt_WWD = Opt("WinWaitDelay", 0)
$hActive = WinGetHandle("[ACTIVE]")
WinSetState($hWnd, "", @SW_RESTORE)
WinActivate($hActive)
WinWaitActive($hActive)
Opt("WinWaitDelay", $iOpt_WWD)
EndIf
If $iWidth = -1 Then $iWidth = _WinAPI_GetWindowWidth($hWnd)
If $iHeight = -1 Then $iHeight = _WinAPI_GetWindowHeight($hWnd)
$hDDC = _WinAPI_GetDC($hWnd)
$hCDC = _WinAPI_CreateCompatibleDC($hDDC)
$hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iWidth, $iHeight)
_WinAPI_SelectObject($hCDC, $hBMP)
DllCall("User32.dll", "int", "PrintWindow", "hwnd", $hWnd, "hwnd", $hCDC, "int", 0)
_WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, 0, 0, 0x00330008)
_WinAPI_ReleaseDC($hWnd, $hDDC)
_WinAPI_DeleteDC($hCDC)
If IsArray($aPos) Then
WinMove($hWnd, "", $aPos[0], $aPos[1])
WinSetState($hWnd, "", @SW_HIDE)
ElseIf IsHWnd($hActive) Then
WinSetState($hWnd, "", @SW_MINIMIZE)
EndIf
If $sFileName = "" Then Return $hBMP
_ScreenCapture_SaveImage($sFileName, $hBMP, True)
EndFunc