如何使用UWP图形。在没有GraphicsCapturePicker的情况下捕获API?

如何使用UWP图形。在没有GraphicsCapturePicker的情况下捕获API?,uwp,directx-11,screen-capture,Uwp,Directx 11,Screen Capture,有没有一种方法可以使用UWP Graphic.Capture API来捕获屏幕,而不向用户显示GraphicsCapture Picker? 我希望我的程序在没有用户干预的情况下捕获和记录屏幕 谢谢 在microsoft文档中,Direct3D11CaptureFramePool和GraphicsCaptureSession是通过显示GraphicsCapturePicker创建的 发送给用户,并使用用户选择(GraphicsCaptureItem)创建框架池和会话 var picker = n

有没有一种方法可以使用UWP Graphic.Capture API来捕获屏幕,而不向用户显示GraphicsCapture Picker? 我希望我的程序在没有用户干预的情况下捕获和记录屏幕 谢谢

在microsoft文档中,Direct3D11CaptureFramePool和GraphicsCaptureSession是通过显示GraphicsCapturePicker创建的 发送给用户,并使用用户选择(GraphicsCaptureItem)创建框架池和会话

var picker = new GraphicsCapturePicker();

//show dialog box with the user and wait for user selection
GraphicsCaptureItem item = await picker.PickSingleItemAsync();
Direct3D11CaptureFramePool framePool = 
Direct3D11CaptureFramePool.Create(...)
GraphicsCaptureSession session = 
framePool.CreateCaptureSession(item);
session.StartCapture();

有没有办法在没有对话框的情况下执行此操作?

如果您只想捕获应用程序的屏幕截图,可以使用API。使用这些API,您不需要“GraphicsCapturePicker”对话框

我为您制作了一个简单的代码示例:

AppRecordingManager manager = AppRecordingManager.GetDefault();
var status = manager.GetStatus();
if (status.CanRecord || status.CanRecordTimeSpan)
{
    var result = await manager.SaveScreenshotToFilesAsync(ApplicationData.Current.LocalFolder,"screnshot",AppRecordingSaveScreenshotOption.HdrContentVisible,manager.SupportedScreenshotMediaEncodingSubtypes);
    Debug.WriteLine(result.Succeeded);
    if (result.Succeeded)
    {
        foreach (var item in result.SavedScreenshotInfos)
        {
            Debug.WriteLine(item.File.DisplayName);
        }
    }
    else
    {
        Debug.WriteLine(result.ExtendedError.Message);
    }
}

如果您还想捕获其他窗口的屏幕截图,那么就没有其他内置的UWP API可供您使用。您必须使用“GraphicsCapturePicker”。

我在这里找到了microsoft示例
有一种方法可以通过hwnd

Thx为答案创建GraphicsCaptureItem实例。我在寻找屏幕截图,而不仅仅是我的应用程序截图。@nadavi如果是这样,你就必须使用
GraphicsCapturePicker
。您可以尝试在提交“功能请求”。请在您的answer@Maccesch对不起,我不知道它的本质,它是关于Windows核心层的。我只是在Windows上搜索屏幕截图。找到了样本和这个问题。我希望我能在将来帮助任何看到这个问题的人。