I am trying to take a screenshot of a window that is not in the foreground.
I read the help file and I searched the forum. But somehow I just can't get it to work...
I tried multiple versions. Noone work. They simply capture my current screen OR capture a small black rectangle.
#include <ScreenCapture.au3>
Main()
Func Main()
Local $handle
$handle = WinGetHandle("Untitled - Notepad");
; Capture window
_ScreenCapture_CaptureWnd(@MyDocumentsDir & "\test.jpg", $handle);
Then try this:
#include <GDIPlus.au3>
_GDIPlus_Startup()
Global $handle = WinGetHandle("[CLASS:Notepad]")
Global $hBitmap = Capture_Window($handle, _WinAPI_GetWindowWidth($handle), _WinAPI_GetWindowHeight($handle))
_GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\test.jpg")
_GDIPlus_Shutdown()
ShellExecute(@ScriptDir & "\test.jpg")
Func Capture_Window($hWnd, $w, $h)
If Not IsHWnd($hWnd) Then Return SetError(1, 0, 0)
If Int($w) < 1 Then Return SetError(2, 0, 0)
If Int($