Engineering7 min read

How Apps Hide Windows From Screen Capture: SetWindowDisplayAffinity and WDA_EXCLUDEFROMCAPTURE

Short answer

Windows lets an app call SetWindowDisplayAffinity(hwnd, WDA_EXCLUDEFROMCAPTURE) on one of its own top-level windows. From then on, the Desktop Window Manager leaves that window out of screen capture. It still shows on the monitor, but screen shares, recordings and screenshots see whatever is behind it. The value needs Windows 10 version 2004 or later; earlier versions show a black box instead.

The API

BOOL SetWindowDisplayAffinity(HWND hWnd, DWORD dwAffinity);

// Hide this window from capture, keep it on the monitor
SetWindowDisplayAffinity(hwnd, WDA_EXCLUDEFROMCAPTURE);

// Back to normal
SetWindowDisplayAffinity(hwnd, WDA_NONE);

The three affinity values

ValueOn your monitorIn a capture
WDA_NONENormalNormal
WDA_MONITORNormalA black rectangle where the window is
WDA_EXCLUDEFROMCAPTURENormalNot there at all; the content behind it shows through

WDA_MONITOR dates back to Windows 7 and was meant for content protection: the capture shows the window’s frame with nothing in it. WDA_EXCLUDEFROMCAPTURE (value 0x11) arrived in Windows 10 version 2004. Microsoft’s example use is a recording toolbar that shouldn’t appear in its own recording. On older versions of Windows, the call falls back to WDA_MONITOR behavior, which is why some tools show a black box on outdated systems.

Why it works across Zoom, Teams, Meet and OBS

On modern Windows, the Desktop Window Manager (DWM) composes every window into the final image. Screen capture APIs such as Windows Graphics Capture, DXGI desktop duplication and GDI screenshots all get their pixels from DWM. Because DWM applies the affinity, a window excluded there is missing from every one of them, so no single meeting app needs to support it.

OBS has several capture methods. With Display Capture set to Windows 10 (1903 and up), excluded windows are left out reliably. Older or game-specific capture paths may behave differently. See hiding windows from OBS and Discord.

The catch: only for your own windows

Microsoft’s documentation is explicit: the window must belong to the calling process. You can protect your own app’s windows easily, but you can’t simply call the function on Slack’s or Chrome’s window from another program. It fails.

Tools that hide other apps’ windows, including Cloakly and the open-source Invisiwind, get around this by running a small piece of code inside the target process, which then sets the affinity on its own window. This is a standard Windows technique, but it is also why antivirus software sometimes flags such tools. Signed, Store-distributed builds help.

In frameworks

  • Electron: win.setContentProtection(true) sets the display affinity for you on Windows.
  • Tauri / Rust: call SetWindowDisplayAffinity through the windows crate with the window’s HWND.
  • WPF / WinForms: P/Invoke SetWindowDisplayAffinity from user32.dll with the window handle.

What it doesn’t protect against

  • Cameras. Anyone can photograph or film the monitor. Microsoft’s own documentation makes this point: it is not a security or DRM feature.
  • Hardware capture. HDMI capture cards and screen mirroring to a TV take the final display output, where the window is visible.
  • Child windows and pop-ups. The affinity applies to a top-level window. Menus, tooltips or dialogs that an app opens as separate windows need their own affinity.
  • Composition off. It only works while DWM is composing the desktop (always the case on Windows 8 and later).

What about macOS?

macOS has a comparable per-window setting (NSWindow.sharingType = .none), but Apple has changed how screen capture treats it across macOS versions, so results vary by OS version and capture method. Cloakly is Windows-only.

Share your whole screen, minus the private parts

Don’t want to build it yourself? Cloakly applies this to any window you choose, with rules that re-apply it automatically when a screen share starts. Download Cloakly for Windows.

Protect your next screen share.

Hide Slack, banking tabs, API keys, and password managers from Zoom, Teams, and Discord — in seconds.

Recommended Reads

Comparisons

Cloakly vs Invisiwind (and Other Free Ways to Hide Windows While Screen Sharing)

An honest comparison of Cloakly and Invisiwind, the free open-source window hider, plus the other free options for keeping private windows out of a screen share on Windows.

Streaming

How to Hide a Window From OBS and Discord Streams (Without Leaking Personal Info)

Keep chats, notifications and private windows out of your OBS recordings and Discord Go Live streams. Built-in options for each app, and how to hide a window while still capturing your full screen.