Hi, ich versuche ein Hintergrundfenster abzufotografieren. Dank chip habe ich dazu eine Funktion aus dem englischen Forum. Irgendwie schaffe ich es aber nicht, sie richtig anzuwenden; die Datei wird zwar erstellt, auch in der richtigen Größe, sie ist jedoch komplett schwarz.
Spoiler anzeigen
#include <WinAPI.au3>
#include <GDIPlus.au3>
_GDIPlus_Startup()
$hGUI=WinGetHandle("Posteingang")
$hBitmap = _CaptureWindow ($hGUI)
$hBitmap2=_GDIPlus_BitmapCreateFromHBITMAP ($hBitmap)
_GDIPlus_ImageSaveToFile($hBitmap2,@MyDocumentsDir & "\GDIPlus_Image.jpg")
Func _CaptureWindow($hWnd)
Local $WM_PAINT = 0x000F
Local $WM_PRINT = 0x317
Local $PRF_CHILDREN = 0x10; Draw all visible child windows.
Local $PRF_CLIENT = 0x4 ; Draw the window's client area.
Local $PRF_OWNED = 0x20 ; Draw all owned windows.
Local $PRF_NONCLIENT = 0x2 ; Draw the window's Title area.
Local $PRF_ERASEBKGND = 0x8 ; Erases the background before drawing the window
Local $pos = WinGetPos($hWnd)
Local $Width = $pos[2]
Local $Height = $pos[3]
Local $hDC = _WinAPI_GetDC($hWnd)
Local $memDC = _WinAPI_CreateCompatibleDC($hDC)
Local $memBmp = _WinAPI_CreateCompatibleBitmap($hDC, $Width, $Height)
_WinAPI_SelectObject ($memDC, $memBmp)
[/autoit] [autoit][/autoit] [autoit]Local $Ret = _SendMessage($hWnd, $WM_PAINT, $memDC, 0)
$Ret = _SendMessage($hWnd, $WM_PRINT, $memDC, BitOR($PRF_CHILDREN , $PRF_CLIENT, $PRF_OWNED, $PRF_NONCLIENT, $PRF_ERASEBKGND))
Local $hBMP=_GDIPlus_BitmapCreateFromHBITMAP($memBmp)
Local $hHBITMAP=_GDIPlus_BitmapCreateHBITMAPFromBitmap($hBMP)
_WinAPI_DeleteObject($hDC)
_WinAPI_ReleaseDC($hWnd, $hDC)
_WinAPI_DeleteDC($memDC)
_WinAPI_DeleteObject ($memBmp)
_WinAPI_DeleteDC($hDC)
Return $hHBITMAP
EndFunc ;==>_CaptureWindow()