DesktopDuplication 1.0.1

.NET Core 3.1
dotnet add package DesktopDuplication --version 1.0.1
NuGet\Install-Package DesktopDuplication -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DesktopDuplication" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DesktopDuplication --version 1.0.1
#r "nuget: DesktopDuplication, 1.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install DesktopDuplication as a Cake Addin
#addin nuget:?package=DesktopDuplication&version=1.0.1

// Install DesktopDuplication as a Cake Tool
#tool nuget:?package=DesktopDuplication&version=1.0.1

Desktop Duplication API for .NET Core

Receive desktop frame data in real time, using the Windows 8 Desktop Duplication API.

Install using NuGet

How to use

Initialization

try
{
    desktopDuplicator = new DesktopDuplicator(0);
    // Desktop Duplication API initialized
}
catch (Exception ex)
{
    MessageBox.Show("An error occurred initializing the screen capture module.\nException: \n" + ex.ToString());
}

Screen Capture

public static Bitmap GetNextFrame()
{
    try
    {
        DesktopFrame frame = desktopDuplicator.GetLatestFrame();
        if (frame != null)
        {
            Bitmap frameBitmap = frame.DesktopImage;
            return frameBitmap;

        }
    }
    catch (Exception)
    {
        desktopDuplicator.Dispose();
        desktopDuplicator = new DesktopDuplicator(0);
        // Don't worry, exceptions are expected to happen
    }
    return null;
}

DesktopDuplicationException exceptions can occur when there is a change in the display mode, or a new frame isn't available yet. This can happen as a result of switching to a full-screen app, for example. The DesktopDuplicator object needs to be reinitialized because the SharpDX output duplication must be created for the specific display mode. You must call Dispose on the DesktopDuplicator object before creating a new one, or you will have memory leaks.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp3.1
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 526 6/17/2020
1.0.0 318 6/17/2020