Repository: nvaccess/nvda

Issue:
Impossible to use any UIA control in latest Alpha

### Steps to reproduce:
1. Try to access any UIA application - list of files in Windows Explorer search box in menu start etc.

### Actual behavior:
Error sound plays and the following is in the log:
```
error executing event: gainFocus on <NVDAObjects.Dynamic_UIItemListItemUIA object at 0x05492D78> with extra args of {}
Traceback (most recent call last):
  File "eventHandler.pyc", line 246, in executeEvent
  File "eventHandler.pyc", line 96, in __init__
  File "eventHandler.pyc", line 105, in next
  File "appModules\explorer.pyc", line 415, in event_gainFocus
  File "eventHandler.pyc", line 105, in next
  File "NVDAObjects\UIA\__init__.pyc", line 1142, in event_gainFocus
  File "NVDAObjects\__init__.pyc", line 1137, in event_gainFocus
  File "NVDAObjects\__init__.pyc", line 1005, in reportFocus
  File "speech\__init__.pyc", line 449, in speakObject
  File "speech\__init__.pyc", line 491, in getObjectSpeech
  File "speech\__init__.pyc", line 355, in getObjectPropertiesSpeech
  File "baseObject.pyc", line 42, in __get__
  File "baseObject.pyc", line 146, in _getPropertyViaCache
  File "NVDAObjects\UIA\__init__.pyc", line 1465, in _get_states
  File "NVDAObjects\UIA\__init__.pyc", line 836, in _getUIACacheablePropertyValue
  File "comtypesMonkeyPatches.pyc", line 27, in __call__
_ctypes.COMError: (-2147024809, 'A parameter is incorrect.', (None, None, None, 0, None))

```

### Expected behavior:
No errors and controls should be readable.
### System configuration
#### NVDA installed/portable/running from source:
Tested with portable and from sources.

#### NVDA version:
NVDA version alpha-22132,d90b24e7
#### Windows version:
Windows 7 X64
#### Name and version of other software in use when reproducing the issue:
None
#### Other information about your system:

### Other questions
#### Does the issue still occur after restarting your computer?
Yes
#### Have you tried any other versions of NVDA? If so, please report their behaviors.
2020.4 works okay.
#### If add-ons are disabled, is your problem still occurring?
Yes
#### Did you try to run the COM registry fixing tool in NVDA menu / tools?
No


Discussion:
cc @michaelDCurran
I cannot reproduce this on windows 10 20h2.

 

 

From: Łukasz Golonka ***@***.***> 
Sent: Thursday, March 25, 2021 8:48 PM
To: nvaccess/nvda ***@***.***>
Cc: Subscribed ***@***.***>
Subject: [nvaccess/nvda] Impossible to use any UIA control in latest Alpha (#12227)

 


Steps to reproduce:


1.	Try to access any UIA application - list of files in Windows Explorer search box in menu start etc.


Actual behavior:


Error sound plays and the following is in the log:

error executing event: gainFocus on <NVDAObjects.Dynamic_UIItemListItemUIA object at 0x05492D78> with extra args of {}
Traceback (most recent call last):
  File "eventHandler.pyc", line 246, in executeEvent
  File "eventHandler.pyc", line 96, in __init__
  File "eventHandler.pyc", line 105, in next
  File "appModules\explorer.pyc", line 415, in event_gainFocus
  File "eventHandler.pyc", line 105, in next
  File "NVDAObjects\UIA\__init__.pyc", line 1142, in event_gainFocus
  File "NVDAObjects\__init__.pyc", line 1137, in event_gainFocus
  File "NVDAObjects\__init__.pyc", line 1005, in reportFocus
  File "speech\__init__.pyc", line 449, in speakObject
  File "speech\__init__.pyc", line 491, in getObjectSpeech
  File "speech\__init__.pyc", line 355, in getObjectPropertiesSpeech
  File "baseObject.pyc", line 42, in __get__
  File "baseObject.pyc", line 146, in _getPropertyViaCache
  File "NVDAObjects\UIA\__init__.pyc", line 1465, in _get_states
  File "NVDAObjects\UIA\__init__.pyc", line 836, in _getUIACacheablePropertyValue
  File "comtypesMonkeyPatches.pyc", line 27, in __call__
_ctypes.COMError: (-2147024809, 'A parameter is incorrect.', (None, None, None, 0, None))
 

Expected behavior:


No errors and controls should be readable.


System configuration


NVDA installed/portable/running from source:


Tested with portable and from sources.


NVDA version:


NVDA version alpha-22132,d90b24e7


Windows version:


Windows 7 X64


Name and version of other software in use when reproducing the issue:


None


Other information about your system:


Other questions


Does the issue still occur after restarting your computer?


Yes


Have you tried any other versions of NVDA? If so, please report their behaviors.


2020.4 works okay.


If add-ons are disabled, is your problem still occurring?


Yes


Did you try to run the COM registry fixing tool in NVDA menu / tools?


No

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <https://github.com/nvaccess/nvda/issues/12227> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/ACVCDE2TST2NAUOPQCNB3VTTFOHQLANCNFSM4Z2AMOEQ> .  <https://github.com/notifications/beacon/ACVCDE5KAICW2ZM5OAINNWLTFOHQLA5CNFSM4Z2AMOE2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4MRERG6A.gif> 


I can not repro either.  Can you perhaps give an exact STR, showing where it 
stops working?

Also, please run the com reg fixing tool.

This is a regression from #12210
We'll just need a try except catching COMError around the fetching of the annotationTypes property in _get_states. Looks like Windows 7 UIA core can't handle that property ID.

Resolving patch:
diff --git a/source/NVDAObjects/UIA/__init__.py b/source/NVDAObjects/UIA/__init__.py
--- a/source/NVDAObjects/UIA/__init__.py
+++ b/source/NVDAObjects/UIA/__init__.py
@@ -1193,10 +1193,14 @@ def _get_UIASelectionPattern(self):
 		return self.UIASelectionPattern
 
 	def _get_UIASelectionPattern2(self):
-		self.UIASelectionPattern2 = self._getUIAPattern(
-			UIAHandler.UIA_SelectionPattern2Id,
-			UIAHandler.IUIAutomationSelectionPattern2
-		)
+		try:
+			self.UIASelectionPattern2 = self._getUIAPattern(
+				UIAHandler.UIA_SelectionPattern2Id,
+				UIAHandler.IUIAutomationSelectionPattern2
+			)
+		except COMError:
+			# SelectionPattern2 is not available on older Operating Systems such as Windows 7
+			self.UIASelectionPattern2 = None
 		return self.UIASelectionPattern2
 
 	def getSelectedItemsCount(self, maxItems=None):
@@ -1462,7 +1466,11 @@ def _get_states(self):
 				states.add(controlTypes.STATE_CHECKABLE)
 				if s==UIAHandler.ToggleState_On:
 					states.add(controlTypes.STATE_CHECKED)
-		annotationTypes = self._getUIACacheablePropertyValue(UIAHandler.UIA_AnnotationTypesPropertyId)
+		try:
+			annotationTypes = self._getUIACacheablePropertyValue(UIAHandler.UIA_AnnotationTypesPropertyId)
+		except COMError:
+			# annotationTypes cannot be fetched on older Operating Systems such as Windows 7.
+			annotationTypes = None
 		if annotationTypes:
 			if UIAHandler.AnnotationType_Comment in annotationTypes:
 				states.add(controlTypes.STATE_HASCOMMENT)


Test patch: