Use Windows Graphics Capture for content recognition with Screen Curtain and Magnifier - #20664
Merged
Merged
Conversation
Collaborator
|
This is lovely @cary-rowen . |
Contributor
|
Manual testing when running from source code:
No issues. As for DPI, it can be recognized normally after I switch monitors or adjust the scaling settings. |
Contributor
Author
|
Thanks @hwf1324 |
seanbudd
reviewed
Aug 17, 2026
seanbudd
marked this pull request as draft
August 17, 2026 08:49
cary-rowen
marked this pull request as ready for review
August 17, 2026 13:50
seanbudd
approved these changes
Aug 18, 2026
Member
|
Thanks @cary-rowen |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue number:
Follow up #20630
Part of #20480.
Fixes #19164
Summary of the issue:
Content recognition currently uses GDI to capture screen pixels. Screen Curtain causes this capture to return black pixels, while NVDA's built-in Magnifier can cause recognition to receive magnified, cropped or color-transformed pixels instead of the original screen content.
Description of user facing changes:
On supported systems, Windows OCR can now be used while Screen Curtain or NVDA's built-in Magnifier is active. Existing GDI capture behavior is preserved when neither feature is active and when WGC is unavailable for Magnifier.
Description of developer facing changes:
Added a private Python wrapper for the Windows Graphics Capture backend introduced in #20630 and centralized capture selection in
contentRecog.recogUi. Content recognizers using the shared recognition framework receive the same capture behavior. Negative virtual-screen origins are now accepted for monitors positioned left of or above the primary display. No public API changes are introduced.Description of development approach:
GDI remains the default capture path. WGC is used when Screen Curtain is active, or when NVDA's built-in Magnifier is active and WGC is supported. A WGC failure while Magnifier is active falls back to GDI, preserving the previous usable behavior. No GDI fallback is allowed while Screen Curtain is active because it would return pixels from the obscured display. Capture failures and watchdog cancellation are passed through the existing recognition result lifecycle. Enabling Screen Curtain during automatically refreshed recognition is blocked only when WGC is unavailable.
Testing strategy:
Unit tests cover default GDI selection, Screen Curtain and Magnifier failure behavior, watchdog cancellation, Screen Curtain state transitions, negative virtual-screen coordinates and invalid capture dimensions. The focused content recognition test suite and Python lint and formatting checks pass. Windows OCR with Screen Curtain has also been tested manually.
Known issues with pull request:
Further manual testing is pending.
Code Review Checklist: