Skip to content

Add WDA_EXCLUDEFROMCAPTURE support to hide edge light from screen capture#22

Merged
shanselman merged 5 commits intomasterfrom
copilot/exclude-edge-light-capture
Dec 8, 2025
Merged

Add WDA_EXCLUDEFROMCAPTURE support to hide edge light from screen capture#22
shanselman merged 5 commits intomasterfrom
copilot/exclude-edge-light-capture

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 6, 2025

Implements the Windows WDA_EXCLUDEFROMCAPTURE display affinity flag so the edge light remains visible locally but invisible to screen sharing apps (Teams, Zoom) and screenshot tools. Made optional since screenshots won't capture the effect when enabled.

Changes

Core Implementation

  • P/Invoke SetWindowDisplayAffinity with WDA_EXCLUDEFROMCAPTURE (0x00000011)
  • Apply to all window types: main overlay, control toolbar, additional monitors
  • Store Win32 error codes immediately after API calls for accurate debug logging

Settings Persistence

  • JSON configuration in %APPDATA%\WindowsEdgeLight\settings.json
  • Automatic recovery from corrupted files with validation

UI Controls

  • Control toolbar: 🎥 button with state-aware tooltips
  • Tray menu: checkmark toggle for quick access
  • Button opacity reflects active state (1.0 enabled, 0.5 disabled)
// Applied during window initialization
SetWindowDisplayAffinity(hwnd, 
    settings.ExcludeFromCapture ? WDA_EXCLUDEFROMCAPTURE : WDA_NONE);

Setting defaults to false to preserve existing screenshot behavior.

Original prompt

This section details on the original issue you should resolve

<issue_title>Exclude the edge lighting from being captured</issue_title>
<issue_description>use the WDA_EXCLUDEFROMCAPTURE flag so when you are screen sharing, it shouldn't capture.

This should be a setting as well as with this set, you won't be able to take a screenshot with it actually working :)</issue_description>

<agent_instructions>What would this look like? Consider a plan and think about it. If someone shares their screen on teams WHILE using the Edge light, could this flag make it appear invisible to the viewer on the other side?</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits December 6, 2025 22:44
- Add AppSettings class for persistent configuration storage
- Add P/Invoke declarations for SetWindowDisplayAffinity Windows API
- Implement exclude from capture functionality for main and additional monitor windows
- Add tray menu option with checkmark for the feature
- Add control toolbar button (🎥) for quick toggle
- Persist setting across application restarts using JSON configuration
- Update README with comprehensive documentation about screen sharing mode
- Update help dialog to mention the new feature

Co-authored-by: shanselman <2892+shanselman@users.noreply.github.com>
… feature

- Add error handling to SetWindowDisplayAffinity calls with debug logging
- Improve JSON deserialization with validation and error recovery
- Update button tooltip to clearly indicate current state for better accessibility
- Add SetLastError to P/Invoke declaration for proper error reporting

Co-authored-by: shanselman <2892+shanselman@users.noreply.github.com>
- Store error code immediately after API call to ensure accuracy
- Add missing System namespace import in AppSettings.cs

Co-authored-by: shanselman <2892+shanselman@users.noreply.github.com>
Copilot AI changed the title [WIP] Add flag to exclude edge lighting from screen capture Add WDA_EXCLUDEFROMCAPTURE support to hide edge light from screen capture Dec 6, 2025
Copilot AI requested a review from shanselman December 6, 2025 22:53
@shanselman shanselman marked this pull request as ready for review December 8, 2025 04:06
@shanselman shanselman merged commit 606a932 into master Dec 8, 2025
@shanselman shanselman deleted the copilot/exclude-edge-light-capture branch December 8, 2025 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exclude the edge lighting from being captured

2 participants