diff --git a/source/UIAHandler/constants.py b/source/UIAHandler/constants.py index 1b58347de43..fbc14029b52 100644 --- a/source/UIAHandler/constants.py +++ b/source/UIAHandler/constants.py @@ -82,3 +82,6 @@ class WinConsoleAPILevel(enum.IntEnum): # Represents an IMPROVED console that exposes text formatting and a # buffer that does not contain extraneous empty lines. FORMATTED = 2 + # Represents a console that sends UIA notification events for new text, + # making NVDAObjects.behaviors.LiveText unnecessary. + NOTIFYING = 3 diff --git a/source/UIAHandler/utils.py b/source/UIAHandler/utils.py index 26f2635354a..584d94054cb 100644 --- a/source/UIAHandler/utils.py +++ b/source/UIAHandler/utils.py @@ -326,6 +326,16 @@ def _getConhostAPILevel(hwnd: int) -> WinConsoleAPILevel: textArea = UIAElement.buildUpdatedCache( textAreaCacheRequest ).getCachedChildren().GetElement(0) + if ( + textArea.getCurrentPropertyValueEx( + UIAHandler.UIA.UIA_LiveSettingPropertyId, + False + ) + == UIAHandler.UIA.Polite + ): + # microsoft/terminal#12358: modern consoles send UIA notification + # events for new text. + return WinConsoleAPILevel.NOTIFYING UIATextPattern = textArea.GetCurrentPattern( UIAHandler.UIA_TextPatternId ).QueryInterface(UIAHandler.IUIAutomationTextPattern)