# Function Reference

# _ScreenCapture_CaptureWnd

Captures a screen shot of a specified window or controlID

#include <ScreenCapture.au3>
_ScreenCapture_CaptureWnd ( $sFileName, $hWnd [, $iLeft = 0 [, $iTop = 0 [, $iRight = -1 [, $iBottom = -1 [, $bCursor = True]]]]] )

## Parameters

$sFileName | Full path and extension of the image file
$hWnd | Handle to the window to be captured
$iLeft | [optional] X coordinate of the upper left corner of the client rectangle
$iTop | [optional] Y coordinate of the upper left corner of the client rectangle
$iRight | [optional] X coordinate of the lower right corner of the rectangle
$iBottom | [optional] Y coordinate of the lower right corner of the rectangle
$bCursor | [optional] If True the cursor will be captured with the image

## Return Value

Success: | a handle to an HBITMAP if $sFileName is empty, or True If called with $sFileName and the image is successfully saved.
Failure: | Set @error to non-zero.

## Remarks

All coordinates are in client coordinate mode.
If a handle is returned, it must be released using _WinAPI_DeleteObject().

## Related

_WinAPI_DeleteObject

## Example

    #include <ScreenCapture.au3>

    Example()

    Func Example()
        Local $hGUI

        ; Create GUI
        $hGUI = GUICreate("Screen Capture", 400, 300)
        GUISetState(@SW_SHOW)
        Sleep(250)

        ; Capture window
        _ScreenCapture_CaptureWnd(@MyDocumentsDir & "\GDIPlus_Image.jpg", $hGUI)

        ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.jpg")
    EndFunc   ;==>Example