Skip to content

Commit 6d0b097

Browse files
authored
Merge d385881 into b94415e
2 parents b94415e + d385881 commit 6d0b097

2 files changed

Lines changed: 40 additions & 8 deletions

File tree

source/UIAHandler/__init__.py

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# A part of NonVisual Desktop Access (NVDA)
2-
# Copyright (C) 2008-2023 NV Access Limited, Joseph Lee, Babbage B.V., Leonard de Ruijter, Bill Dengler
2+
# Copyright (C) 2008-2024 NV Access Limited, Joseph Lee, Babbage B.V., Leonard de Ruijter, Bill Dengler
33
# This file is covered by the GNU General Public License.
44
# See the file COPYING for more details.
55

@@ -1015,12 +1015,12 @@ def IUIAutomationPropertyChangedEventHandler_HandlePropertyChangedEvent(
10151015

10161016
def IUIAutomationNotificationEventHandler_HandleNotificationEvent(
10171017
self,
1018-
sender,
1019-
NotificationKind,
1020-
NotificationProcessing,
1021-
displayString,
1022-
activityId,
1023-
):
1018+
sender: UIA.IUIAutomationElement,
1019+
NotificationKind: int,
1020+
NotificationProcessing: int,
1021+
displayString: str,
1022+
activityId: str
1023+
) -> None:
10241024
if _isDebug():
10251025
log.debug(
10261026
"handleNotificationEvent called "
@@ -1037,8 +1037,39 @@ def IUIAutomationNotificationEventHandler_HandleNotificationEvent(
10371037
return
10381038
import NVDAObjects.UIA
10391039

1040+
# #16871: some elements do not report native window handle when in fact
1041+
# native window handle is shown via runtime ID.
1042+
# This is seen when handling Windows 11 Voice Access notifications.
1043+
if not (window := self.getNearestWindowHandle(sender)):
1044+
if _isDebug():
1045+
log.debugWarning(
1046+
"HandleNotificationEvent: native window handle not found, consulting runtime ID: "
1047+
f"NotificationProcessing={NotificationProcessing} "
1048+
f"displayString={displayString} "
1049+
f"activityId={activityId}"
1050+
)
1051+
if any(runtimeID := sender.getRuntimeID()):
1052+
# Second item in runtime ID array is native window handle.
1053+
window = runtimeID[1]
1054+
if _isDebug():
1055+
log.debugWarning(
1056+
f"HandleNotificationEvent: native window handle is {window}: "
1057+
f"NotificationProcessing={NotificationProcessing} "
1058+
f"displayString={displayString} "
1059+
f"activityId={activityId}"
1060+
)
1061+
else:
1062+
# No runtime ID (tuple is empty).
1063+
if _isDebug():
1064+
log.debugWarning(
1065+
"HandleNotificationEvent: native window handle not found in runtime ID: "
1066+
f"NotificationProcessing={NotificationProcessing} "
1067+
f"displayString={displayString} "
1068+
f"activityId={activityId}"
1069+
)
1070+
return
10401071
try:
1041-
obj = NVDAObjects.UIA.UIA(UIAElement=sender)
1072+
obj = NVDAObjects.UIA.UIA(windowHandle=window, UIAElement=sender)
10421073
except Exception:
10431074
if _isDebug():
10441075
log.debugWarning(

user_docs/en/changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* NVDA once again relies on events for caret movement in several cases, rather than only on manual querying of the caret position.
1919
* UIA for XAML and WPF text controls. (#16817, @LeonarddeR)
2020
* IAccessible2 for browsers such as Firefox and Chromium based browsers. (#11545, #16815, @LeonarddeR)
21+
* NVDA can announce more UIA notifications in apps such as Windows 11 Voice Access. (#16871, @josephsl)
2122

2223

2324
### Changes for Developers

0 commit comments

Comments
 (0)