#include <GDIPlus.au3>
#include <WinAPIEx.au3>
#include <APIConstants.au3>
_GDIPlus_Startup()
$hBitmap = CaptureWindow(WinGetHandle('[CLASS:Solitaire]'))
_GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\Test.jpg")
_GDIPlus_BitmapDispose($hBitmap)
ShellExecute(@ScriptDir & "\Test.jpg")
_GDIPlus_Shutdown()
Func CaptureWindow($hWnd, $iLeft = 0, $iTop = 0, $iWidth = 0, $iHeight = 0)
Local $hDC, $hMemDC, $hBitmap, $hMemSv, $hSrcDC, $hSrcSv, $hBmp
Local $lWidth = _WinAPI_GetWindowWidth($hWnd)
Local $lHeight = _WinAPI_GetWindowHeight($hWnd)
If (($iLeft > 0) And ($iWidth = 0)) Then
$iWidth = ($lWidth - $iLeft)
EndIf
If (($iTop > 0) And ($iHeight = 0)) Then
$iHeight = ($lHeight - $iTop)
EndIf
If (($iLeft = 0) And ($iWidth = 0)) Then
$iWidth = $lWidth
EndIf
If (($iTop = 0) And ($iHeight = 0)) Then
$iHeight = $lHeight
EndIf
$hDC = _WinAPI_GetWindowDC($hWnd)
$hMemDC = _WinAPI_CreateCompatibleDC($hDC)
$hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $lWidth, $lHeight)
$hMemSv = _WinAPI_SelectObject($hMemDC, $hBitmap)
_WinAPI_PrintWindow($hWnd, $hMemDC)
_WinAPI_DeleteObject($hBitmap)
$hSrcDC = _WinAPI_CreateCompatibleDC($hDC)
$hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight)
$hSrcSv = _WinAPI_SelectObject($hSrcDC, $hBitmap)
_WinAPI_BitBlt($hSrcDC, 0, 0, $iWidth, $iHeight, $hMemDC, $iLeft, $iTop, $SRCCOPY)
_WinAPI_SelectObject($hMemDC, $hMemSv)
_WinAPI_SelectObject($hSrcDC, $hSrcSv)
_WinAPI_DeleteDC($hMemDC)
_WinAPI_DeleteDC($hSrcDC)
_WinAPI_ReleaseDC($hWnd, $hDC)
$hBmp = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
_WinAPI_DeleteObject($hBitmap)
Return $hBmp
EndFunc