XAppCaptureTakeScreenshot

Takes a screenshot.

Syntax

HRESULT XAppCaptureTakeScreenshot(  
         XUserHandle requestingUser,  
         XAppCaptureTakeScreenshotResult* result  
)  

Parameters

requestingUser   _In_
Type: XUserHandle

Handle representing the user requesting the screenshot.

result   _Out_
Type: XAppCaptureTakeScreenshotResult*

Results of the screenshot returned.

Return value

Type: HRESULT

Function result.

Remarks

Note

This function isn't safe to call on a time-sensitive thread. For more information, see Time-sensitive threads.

Note

This function isn't supported on Xbox Game Streaming. See the Requirements section below to see which platforms support it.

XAppCaptureTakeScreenshot takes a screenshot as if the user triggered it. This will show a toast and save the game screenshot. If the game is running in SDR, a single file is generated. If the game is running in HDR, two files are generated, one in HDR and one in SDR format. The screenshot(s) may be uploaded automatically to Xbox Live depending on the user preference. Once the screenshot was taken successfully, the resulting file can be read by opening the screenshot stream with XAppCaptureOpenScreenShotStream and reading the screenshot with XAppCaptureReadScreenshotStream. Both of these function will require that you use the local Id returned in the XAppCaptureTakeScreenshotResult returned from this function.

XAppCaptureTakeScreenshotResult takeScreenshotResult = {0};
XUserHandle user = nullptr;
/* See XUserAddAsync, XUserAddResult on how to initialize XUserHandle */
bool hasHDR = false;

LOG_IF_FAILED(XAppCaptureTakeScreenshot(user, &takeScreenshotResult));

hasHDR = static_cast<bool>(takeScreenshotResult.availableScreenshotFormats & XAppCaptureScreenshotFormatFlag::HDR);

appLog.AddLog("LocalId %s (%s)\n", takeScreenshotResult.localId, hasHDR ? "SDR & HDR" : "SDR only");

Requirements

Header: XAppCapture.h

Library: xgameruntime.lib

Supported platforms: Windows, Xbox One family consoles and Xbox Series consoles

See also

GameDVR Overview
XAppCapture Members
XAppCaptureOpenScreenShotStream
XAppCaptureReadScreenShotStream
XAppCaptureCloseScreenshotStream
XAppCaptureTakeScreenshotResult