0

how to make transparent black square in SetWindowDisplayAffinity? put a picture or transparent background instead of a black square

I need the window not to be visible at all in the video capture

  • 1
    `SetWindowDisplayAffinity` doesn't offer any sort of customization. If you need to capture the contents of a window obscured by another window, you're going to have to use a different screen capture approach. The [Windows.Graphics.Capture](https://learn.microsoft.com/en-us/uwp/api/windows.graphics.capture) namespace may work for you. – IInspectable Dec 13 '21 at 16:14
  • I need to hide the window when capturing the screen – Тахир Мухаметов Dec 13 '21 at 16:24
  • That would be another alternative, depending on whether the window allows that. You could either hide it with a call to `ShowWindow`, [minimize it](https://stackoverflow.com/q/31224092/1889329), or move it to the bottom of the Z-order. – IInspectable Dec 13 '21 at 16:39
  • it is visible to me but to those to whom I show no :) – Тахир Мухаметов Dec 13 '21 at 16:45

1 Answers1

2

I found a solution.

const uint WDA_EXCLUDEFROMCAPTURE = 0x00000011;
SetWindowDisplayAffinity (this.Handle, WDA_EXCLUDEFROMCAPTURE);

I also used it. But it works in Windows 10 version 2004 and above. I tried on new versions of Windows and everything worked out, the window was completely invisible in the screen capture.