Giter Club home page Giter Club logo

Comments (7)

glemselenselv avatar glemselenselv commented on May 18, 2024 1

Shouldn't 19041 come with IsCursorCaptureEnabled support? I tried to use that in a netstandard2.0 project defining this:
PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.19041.1"

ApiInformation.IsTypePresent(@"Windows.Graphics.Capture.GraphicsCaptureSession") results to TRUE but
ApiInformation.IsPropertyPresent(@"Windows.Graphics.Capture.GraphicsCaptureSession", @"IsCursorCaptureEnabled") is FALSE

Am I doing something wrong?

EDIT: Please excuse and ignore my question. I just checked whether I had the right SDK version installed which was not the case.

EDIT 2: Now that I have the right SDK installed I still see those results. Strange...

EDIT 3: gosh Windows10 just really really wasn't finished installing update 2004, so after some more restarts it now works.

I leave this comment here for anyone who might run into the same situation ;-)

from windows.ui.composition-win32-samples.

GuanjunZhuo avatar GuanjunZhuo commented on May 18, 2024 1
if(Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 10))
{
    GraphicsCaptureSession.IsCursorCaptureEnabled = value; // maybe check 
}

The way sometimes does not work in C# constructor.
Even if you set judgment, there may still be errors and errors will pop up.
It may be because C# will check all the property in advance,
so I use reflection to avoid it, AS SHOW BELOW

if (Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent(
"Windows.Foundation.UniversalApiContract", 10))
{
    var aa = GraphicsCaptureSession.GetType().GetProperty("IsCursorCaptureEnabled");
    if (aa != null)
        aa.SetValue(GraphicsCaptureSession,false);
}

Welcome to discuss.

from windows.ui.composition-win32-samples.

robmikh avatar robmikh commented on May 18, 2024

To check if capture is supported at all use the following (assumes Windows.Foundation.UniversalApiContract v1 is at least present):

auto supported = 
    winrt::Windows::Foundation::Metadata::ApiInformation::IsTypePresent(L"Windows.Graphics.Capture.GraphicsCaptureSession") && 
    winrt::Windows::Graphics::Capture::GraphicsCaptureSession::IsSupported();

The first part checks to see if the capture API is present at all. The second part checks whether screen capture is present (e.g. This currently returns false on the Xbox).

To check for individual feature availability, use the following:

auto supported = 
    winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(
        L"Windows.Graphics.Capture.GraphicsCaptureSession", 
        L"IsCursorCaptureEnabled");

PS: It is technically possible to use the capture API if IsSupported returns false, but only by using GraphicsCaptureItem::CreateFromVisual (your own content).

from windows.ui.composition-win32-samples.

jpark37 avatar jpark37 commented on May 18, 2024

I'll use these. Thanks.

from windows.ui.composition-win32-samples.

robmikh avatar robmikh commented on May 18, 2024

No problem!

from windows.ui.composition-win32-samples.

jpark37 avatar jpark37 commented on May 18, 2024

For window capture support as a whole, I'm going back to UniversalApiContract >= 8 for the time being. GraphicsCaptureSession exists on 1809, but IGraphicsCaptureItemInterop does not, so we were falsely reporting support for that version.

from windows.ui.composition-win32-samples.

robmikh avatar robmikh commented on May 18, 2024

Ah sorry, I should have mentioned that. We introduced the capture API before we introduced the Win32 specific interface. Since you rely on that, checking support for UniversalApiContract 8 is certainly the way to go.

from windows.ui.composition-win32-samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.