Skip to content

Allow UIA to work again on Win7 after pr #12210#12233

Merged
michaelDCurran merged 3 commits into
masterfrom
i12227
Mar 26, 2021
Merged

Allow UIA to work again on Win7 after pr #12210#12233
michaelDCurran merged 3 commits into
masterfrom
i12227

Conversation

@michaelDCurran

@michaelDCurran michaelDCurran commented Mar 26, 2021

Copy link
Copy Markdown
Member

Link to issue number:

Fixes #12227

Summary of the issue:

With the merging of pr #12210 it became impossible to interact with UI Automation controls on Windows 7.

  • Fetching the annotationTypes UIA property raises a COMError if not implemented by the control. On newer Operating Systems UIA core returns a default.
  • Fetching the SelectionPattern2 interface also causes a COMError on older Operating Systems if not implemented by the control.

Description of how this pull request fixes the issue:

  • Catch COMError when fetching UIA annotationTypes.
  • Catch COMError when fetching the UIA SelectionPattern2 interface.

Testing strategy:

On Windows 10, With UIA in Excel turned on in NVDA's Advanced settings, interacted with the Excel test spreadsheet on pr #12210, confirming that all properties still read.

Known issues with pull request:

None.

Change log entry:

None needed.

Code Review Checklist:

This checklist is a reminder of things commonly forgotten in a new PR.
Authors, please do a self-review and confirm you have considered the following items.
Mark items you have considered by checking them.
You can do this when editing the Pull request description with an x: [ ] becomes [x].
You can also check the checkboxes after the PR is created.

  • Pull Request description is up to date.
  • Unit tests.
  • System (end to end) tests.
  • Manual tests.
  • User Documentation.
  • Change log entry.
  • Context sensitive help for GUI changes.

…tionTypes UIA property, as an exception may be raised on Windows 7.
@michaelDCurran michaelDCurran requested a review from seanbudd March 26, 2021 00:34
@michaelDCurran

Copy link
Copy Markdown
Member Author

@lukaszgo1 could you please confirm this pr solves the issue for you?

@lukaszgo1

Copy link
Copy Markdown
Contributor

Unfortunately it does not. The traceback is different though"

error executing event: gainFocus on <NVDAObjects.Dynamic_UIItemListItemUIA object at 0x06C2F898> with extra args of {}
Traceback (most recent call last):
  File "eventHandler.py", line 246, in executeEvent
    _EventExecuter(eventName,obj,kwargs)
  File "eventHandler.py", line 96, in __init__
    self.next()
  File "eventHandler.py", line 105, in next
    return func(*args, **self.kwargs)
  File "appModules\explorer.py", line 415, in event_gainFocus
    nextHandler()
  File "eventHandler.py", line 105, in next
    return func(*args, **self.kwargs)
  File "NVDAObjects\UIA\__init__.py", line 1142, in event_gainFocus
    super().event_gainFocus()
  File "NVDAObjects\__init__.py", line 1137, in event_gainFocus
    self.reportFocus()
  File "NVDAObjects\__init__.py", line 1005, in reportFocus
    speech.speakObject(self, reason=controlTypes.OutputReason.FOCUS)
  File "speech\__init__.py", line 449, in speakObject
    sequence = getObjectSpeech(
  File "speech\__init__.py", line 491, in getObjectSpeech
    sequence = getObjectPropertiesSpeech(
  File "speech\__init__.py", line 405, in getObjectPropertiesSpeech
    and obj.selectionContainer
  File "baseObject.py", line 42, in __get__
    return instance._getPropertyViaCache(self.fget)
  File "baseObject.py", line 146, in _getPropertyViaCache
    val=getterMethod(self)
  File "NVDAObjects\UIA\__init__.py", line 1218, in _get_selectionContainer
    if obj.UIASelectionPattern2:
  File "baseObject.py", line 42, in __get__
    return instance._getPropertyViaCache(self.fget)
  File "baseObject.py", line 146, in _getPropertyViaCache
    val=getterMethod(self)
  File "NVDAObjects\UIA\__init__.py", line 1196, in _get_UIASelectionPattern2
    self.UIASelectionPattern2 = self._getUIAPattern(
  File "NVDAObjects\UIA\__init__.py", line 1168, in _getUIAPattern
    punk=self.UIAElement.GetCachedPattern(ID) if cache else self.UIAElement.GetCurrentPattern(ID)
  File "comtypesMonkeyPatches.py", line 27, in __call__
    return super().__call__(*args,**kwargs)
_ctypes.COMError: (-2147024809, 'A parameter is incorrect', (None, None, None, 0, None))

Comment thread source/NVDAObjects/UIA/__init__.py Outdated

@feerrenrut feerrenrut left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes look fine to me, pending confirmation from users that this is fixed.

The unit test / systemtest checkboxes are empty. Do you have some plans for this? It would be great to introduce system tests with office, but I think that is much too big to do off the back of this bug fix.

@michaelDCurran

Copy link
Copy Markdown
Member Author

@lukaszgo1 are there any further errors after annotationTypes and selectionPattern2 exceptions have been handled?

@lukaszgo1

Copy link
Copy Markdown
Contributor

@michaelDCurran No, everything works as it should. Thanks.

@michaelDCurran michaelDCurran merged commit 656ecb5 into master Mar 26, 2021
@michaelDCurran michaelDCurran deleted the i12227 branch March 26, 2021 10:52
@nvaccessAuto nvaccessAuto added this to the 2021.1 milestone Mar 26, 2021
@Brian1Gaff

Brian1Gaff commented Mar 26, 2021 via email

Copy link
Copy Markdown

@michaelDCurran

michaelDCurran commented Mar 26, 2021 via email

Copy link
Copy Markdown
Member Author

@lukaszgo1

Copy link
Copy Markdown
Contributor

@Brian1Gaff could you please test with https://ci.appveyor.com/api/buildjobs/w86gtxym7utyec7v/artifacts/output%2Fnvda_snapshot_pr12228-22161%2C2c4361c6.exe
If the problem does not occur with that build pr #12228 would fix this.

@Brian1Gaff

Brian1Gaff commented Mar 27, 2021 via email

Copy link
Copy Markdown

@Brian1Gaff

Brian1Gaff commented Mar 27, 2021 via email

Copy link
Copy Markdown

@Brian1Gaff

Brian1Gaff commented Mar 27, 2021 via email

Copy link
Copy Markdown

@Brian1Gaff

Brian1Gaff commented Mar 28, 2021 via email

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Impossible to use any UIA control in latest Alpha

5 participants