Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce IUIAutomation5 interface and ability to announce notificati…
…ons in Windows 10 Fall Creators Update and later (#8045) * UIA: support IUIAutomation5 so notification event tracking can be supported. Re #8009. Also includes #7984: in Windows 10 Version 1709 (Fall Creators Update), UIA notification event is introduced for the benefit of screen readers so they can announct needed text. This is part of UIA 5 interface, which NVDA does not support yet. The UIA notification event accepts additional parameters such as notification kind, notification processing constant and activit ID. This is useful for controlling how things should be announced and when. For now, the handler will do nothing. Also, when initializing UIA handler, use UIA 5, and then fall back to UIA 4. * UIA notification event: treat it the same as any other event except for additional kwargs for event execution. Re #8009. Treat UIA notification event just like others except for two things: * A new UIA_notification event will be fired. * The new event will populate kwargs based on arguments for the actual event handling function (sender, displayString, etc.). This means app modules, global plugins, objects and others must include these kwargs when defining this event. * UIA interface: obtain appropriate IUIAutomation interface based on Windows release. Re #8009. A new function named getIUIAInterface (along with a private companion for Windows 10) is introduced to obtain highest supported IUIAutomation interface. Depending on Windows release, it'll return various interfaces. In case of Windows 10, a companion function will return appropriate interface based on build ranges. * UIA notification event: add the handler if IUIAutomation5 is in use. Re #7984. If IUIAutomation5 is in use, add notificaiton event handler, otherwise COM error is thrown. Also, instead of relying solely on Python MRO to retrieve UIA interface, save the string somewhere for reference purposes and for future use. * UIA notification event: camel case for consistency. * NVDAObjects/UIA: handle UIA notification event from object level. Re #8009. The base implementation for UIA notification handler will just speak whatever notification it receives. Subclasses are more than welcome to add further processing routines. * UIA interface: query interface from version 5 downwards. Re #8009. Comments from @LeonarddeR and @michaelDCurran: build ranges aren't useful, subsequently proven to be true. As an alternative, query interfaces from newest to oldest, which does allow NVDA to use IUIAutomation5 interface from source. Also, this means getIUIAInterface function is no longer necessary. * UIA support: check isinstance, no more IUIAVersion string. Re #8009. Commented by @LeonarddeR and @michaelDCurran: check isinstance instead of keeping an eye on IUIA interface string. * UIA notification: do not include sender argument. Re #8009. Reviewed by @michaelDCurran (NV Access): sender argument is redundant. * UIA notification: do not announce notifications from background apps. Re #8045.
- Loading branch information