How to remove Yellow Boarder Capture Indicator from Windows.Graphics.Capture-ing (for desktop targeted applications)

vb 276 Reputation points
2020-09-26T18:47:08.693+00:00

I’m using Windows.Graphics.Capture in desktop application.
When capturing of a window starts, “Yellow Boarder Capture Indicator” shows up like at this image:

28505-49c024af0f138797eb0b9eb8c169f892.png

I suppose this is because UWP security, for to inform user something is being captured.
But, my application is desktop based (WPF, Win32, DirectX).

In desktop environment there are more ways to capture from screen (using DXGI OutputDuplication or GDI BitBlt),
where “Yellow Boarder Capture Indicator” does not show up (Thanks God!).
So UWP security is not in consideration for desktop app! (At desktop, if "malign" desktop app can get information from screen without
user being informed, why force all other "good" desktop applications not to be able use Windows.Graphics.Capture without "Yellow border"?)

As I can see, you can remove “Yellow border” only in case for in-application window & window is DWM-DWMWA_CLOAK.
But, my scenario demands not to do DWM-DWMWA_CLOAK. Also, in my scenario, RenderTargetBitmap is also not an option... because output is not exact, capture performance is bad and is WPF specific. Nor is BitmapCacheBrush because dose not capture window to bitmaps...(and is WPF specific)

Is there a way to remove "Yellow Boarder Capture Indicator" for desktop application?
At least, to remove “Yellow border indicator” for case: Desktop app & self-Process created & visible window?

Thanks in advance,
Vladimir

P.S. Very nice thing is that window Windows.Graphics.Capture-ing preserves alpha transparency and avoids obscurities, where other capturing methods does not!
It is fast, can produce animated chains like: Window live content -> DirectX (2D/3D) HLSL custom effect -> DirectCompostition or Visual layer.
After 10 years, finally one can see some progress! :D
(Though, GDI BitBlt can capture window alpha transparently but only for Win32 DC rendered windows, not for WPF & others).

Universal Windows Platform (UWP)
Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,691 questions
{count} votes

Accepted answer
  1. Gil 1 226 Reputation points
    2022-01-14T23:13:46.017+00:00

    See the answer here:
    https://github.com/microsoft/Windows.UI.Composition-Win32-Samples/issues/97#issuecomment-1013443790

    I post there code example how to disable the border.

    1. Add: [ComImport]
      [InterfaceType(ComInterfaceType.InterfaceIsIInspectable)]
      [Guid("f2cdd966-22ae-5ea1-9596-3a289344c3be")]
      public interface IGraphicsCaptureSession3
      {
      bool IsBorderRequired { get; set; }
      }
    2. Add the following code after you have session object (returned from framePool.CreateCaptureSession()) and before the call to session.StartCapture(); : var pUnk = Marshal.GetIUnknownForObject(session);
      var session3 = Marshal.GetObjectForIUnknown(pUnk) as IGraphicsCaptureSession3;
      session3.IsBorderRequired = false;

    165245-image.png

    2 people found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Hayden Lawson 1 Reputation point
    2020-10-27T10:20:14.513+00:00

    basically as far as i know its a security thing to tell you something is being captured and that there isn't an easy way to get rid of it without cropping the end capture or something. i'm not sure why you would want to remove it but i guess you do you. as far as i know its just not possible. sorry for not being able to help :)

    0 comments No comments

  2. vb 276 Reputation points
    2020-10-27T13:32:07.033+00:00

    Sorry @Hayden Lawson ...but I would accept your answer if was like this: Currently, there is no possible way to remove YB.

    I am talking about removing YB primary in this scenario...

    You are capturing you own application window. In this situation security reason is not applicable ... cause you can fetch data from your application as you can like and "steal" user data that user already is entering in same application. (So, not removing YB for capturing other application windows.)
    (Also, I am talking about desktop application. NOT UWP)

    P.S. Why I need it is Top Secret!!! LOL

    But, I will manage..."few" processor clocks more, "few" graphic frame times lost...but, it will work!

    It is miracle that Windows.Graphics.Capture even exists!

    OK, how long are WPF & DWM there? 15-years? Currently, in WPF there is no possible way to get capture of your own window except using RenderTargetBitmap that is slow and give you not identical render! Especially RenderTargetBitmap fails to render 3D view-port correctly. For classic Win32 window, BitBlt...also slow.
    DWM has buffered image of a window...it is just matter of DX copy resource to get the image...like cca 1ms...no rendering needed, it is already here!
    Now, after 15 years, there is Windows.Graphics.Capture, that does this, but, of course, here is YB...LOL...15 years slow but you can see the progress! LOL!

    (Even Windows.Graphics.Capture is slow...you must initialize is...+100ms price tag. OK, you can pre-initialize it and take hit on memory tag...and for what? For something that is already in DWM memory, 1ms away? LOL!!!)
    Sorry Microsoft, that's no PRO.

    P.S.S. I need it for effect transformations like... Window (WPF/Win32) live content -> DirectX (2D/3D) HLSL custom effect -> DirectComposition or Visual layer.