Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include a list of supported UIA patterns into the developer info #5712

Closed
dave090679 opened this issue Jan 26, 2016 · 12 comments · Fixed by #7992
Closed

include a list of supported UIA patterns into the developer info #5712

dave090679 opened this issue Jan 26, 2016 · 12 comments · Fixed by #7992
Labels
Milestone

Comments

@dave090679
Copy link

hi guys,

inspired by the jaws touch cursor's object properies dialog, I wrote some code to generate a list of supported UIA patterns for the current navigator object. IMHO it would make sense to include such a patterns list into the developer info generated by nvda+f1.

To use my global plugin, press nvda+shift+f1. If the navigator is placed on a uia object, the patterns list is displayed as a flash message and it's also written to the nvda log (as an info istring). If the navigator isn't placed onto a uia object, an error message is displayed.

I've tested the global plugin with various (non)UIA objects in Windows 7 x64 as well as in Kaspersky Internet Security 2016.

You can get the global plugin from my dropbox: https://dl.dropboxusercontent.com/u/67471/uia_patterns.py

happy testing

Dave

@josephsl
Copy link
Collaborator

Hi, Could you attach the plug-in as a zip file so someone can code review it? Note that UIA patterns wil work well for UIA objects (there are broken UIA objects, so be careful with those). Thanks.

From: dave090679 [mailto:notifications@github.com]
Sent: Tuesday, January 26, 2016 2:26 AM
To: nvaccess/nvda nvda@noreply.github.com
Subject: [nvda] include a list of supported UIA patterns into the developer info (#5712)

hi guys,

inspired by the jaws touch cursor's object properies dialog, I wrote some code to generate a list of supported UIA patterns for the current navigator object IMHO it would make sense to include such a patterns list into the developer info generated by nvda+f1

To use my global plugin, press nvda+shift+f1 If the navigator is placed on a uia object, the patterns list is displayed as a flash message and it's also written to the nvda log (as an info istring) If the navigator isn't placed onto a uia object, an error message is displayed

I've tested the global plugin with various (non)UIA objects in Windows 7 x64 as well as in Kaspersky Internet Security 2016

You can get the global plugin from my dropbox: https://dldropboxusercontentcom/u/67471/uia_patternspy

happy testing

Dave


Reply to this email directly or view it on GitHub #5712 .

@dave090679
Copy link
Author

hi all,

This is a first try attaching my code as a blank .py file. I tried this
using the website, but it told me that "this file type is not supported".

happy testing

Dave

import ui
from logHandler import log
from NVDAObjects.UIA import UIA
import globalPluginHandler
import UIAHandler
import api
class GlobalPlugin(globalPluginHandler.GlobalPlugin):
__gestures = {
"kb:nvda+shift+f1": "listsupportedpatterns"
}
def script_listsupportedpatterns(self, gesture):
uiapatternstonames = {
UIAHandler.UIA_IsAnnotationPatternAvailablePropertyId: 'annotation pattern',
UIAHandler.UIA_IsDockPatternAvailablePropertyId: 'dock pattern',
UIAHandler.UIA_IsDragPatternAvailablePropertyId: 'drag pattern',
UIAHandler.UIA_IsDropTargetPatternAvailablePropertyId: 'drop target pattern',
UIAHandler.UIA_IsExpandCollapsePatternAvailablePropertyId: 'expand and collapse pattern',
UIAHandler.UIA_IsGridItemPatternAvailablePropertyId: 'grid item pattern',
UIAHandler.UIA_IsGridPatternAvailablePropertyId: 'grid pattern',
UIAHandler.UIA_IsInvokePatternAvailablePropertyId: 'invoke pattern',
UIAHandler.UIA_IsItemContainerPatternAvailablePropertyId: 'item container pattern',
UIAHandler.UIA_IsLegacyIAccessiblePatternAvailablePropertyId: 'legacy IAccessible pattern',
UIAHandler.UIA_IsMultipleViewPatternAvailablePropertyId: 'multiple view pattern',
UIAHandler.UIA_IsObjectModelPatternAvailablePropertyId: 'object model pattern',
UIAHandler.UIA_IsRangeValuePatternAvailablePropertyId: 'range value pattern',
UIAHandler.UIA_IsScrollItemPatternAvailablePropertyId: 'scroll item pattern',
UIAHandler.UIA_IsScrollPatternAvailablePropertyId: 'scroll pattern',
UIAHandler.UIA_IsSelectionItemPatternAvailablePropertyId: 'selection item pattern',
UIAHandler.UIA_IsSelectionPatternAvailablePropertyId: 'selection pattern',
UIAHandler.UIA_IsSpreadsheetItemPatternAvailablePropertyId: 'spread sheet item pattern',
UIAHandler.UIA_IsSpreadsheetPatternAvailablePropertyId: 'spread sheet pattern',
UIAHandler.UIA_IsStylesPatternAvailablePropertyId: 'style pattern',
UIAHandler.UIA_IsSynchronizedInputPatternAvailablePropertyId: 'Synchronized input pattern',
UIAHandler.UIA_IsTableItemPatternAvailablePropertyId: 'table item patern',
UIAHandler.UIA_IsTablePatternAvailablePropertyId: 'table pattern',
UIAHandler.UIA_IsTextChildPatternAvailablePropertyId: 'text child pattern',
UIAHandler.UIA_IsTextEditPatternAvailablePropertyId: 'text edit pattern',
UIAHandler.UIA_IsTextPattern2AvailablePropertyId: 'text pattern 2',
UIAHandler.UIA_IsTextPatternAvailablePropertyId: 'text pattern',
UIAHandler.UIA_IsTogglePatternAvailablePropertyId: 'toggle pattern',
UIAHandler.UIA_IsTransformPattern2AvailablePropertyId: 'transform pattern 2',
UIAHandler.UIA_IsTransformPatternAvailablePropertyId: 'transform pattern',
UIAHandler.UIA_IsValuePatternAvailablePropertyId: 'value pattern',
UIAHandler.UIA_IsVirtualizedItemPatternAvailablePropertyId: 'virtualized item pattern',
UIAHandler.UIA_IsWindowPatternAvailablePropertyId: 'window pattern'
}
l = list()
nav = api.getNavigatorObject()
if not isinstance(nav, UIA):
ui.message('the current navigator object is not a uia object.')
return
else:
for p in uiapatternstonames.keys():
result = False
try:
result = nav.UIAElement.GetCurrentPropertyValue(p)
except:
pass
if result:
l.append(uiapatternstonames[p])
str = ', '.join(l)
if str:
log.info('supported patterns for navigator object: '+str)
ui.message(str)

@dave090679
Copy link
Author

dave090679 commented Jan 27, 2016 via email

@derekriemer
Copy link
Collaborator

Simply rename the .py to .py.txt and it should work.
Thanks.

On 1/27/2016 12:21 AM, dave090679 wrote:

hi all,

this is a second try to attach the code as a 7zip compressed zip file.
When I try to do this using the website, it says that it "cannot process
the file".

happy testing

Dave


Reply to this email directly or view it on GitHub
#5712 (comment).


Derek Riemer
  • Department of computer science, third year undergraduate student.
  • Proud user of the NVDA screen reader.
  • Open source enthusiast.
  • Member of Bridge Cu
  • Avid skiier.

Websites:
Honors portfolio http://derekriemer.com
Awesome little hand built weather app!
http://django.derekriemer.com/weather/

email me at derek.riemer@colorado.edu mailto:derek.riemer@colorado.edu
Phone: (303) 906-2194

@dave090679
Copy link
Author

Hi Drek,

Here comes a third (and I hope final) Try to attach a file. This time,
It is a py.txt renames copy of the source code.

happy testing

Dave

import ui
from logHandler import log
from NVDAObjects.UIA import UIA
import globalPluginHandler
import UIAHandler
import api
class GlobalPlugin(globalPluginHandler.GlobalPlugin):
__gestures = {
"kb:nvda+shift+f1": "listsupportedpatterns"
}
def script_listsupportedpatterns(self, gesture):
uiapatternstonames = {
UIAHandler.UIA_IsAnnotationPatternAvailablePropertyId: 'annotation pattern',
UIAHandler.UIA_IsDockPatternAvailablePropertyId: 'dock pattern',
UIAHandler.UIA_IsDragPatternAvailablePropertyId: 'drag pattern',
UIAHandler.UIA_IsDropTargetPatternAvailablePropertyId: 'drop target pattern',
UIAHandler.UIA_IsExpandCollapsePatternAvailablePropertyId: 'expand and collapse pattern',
UIAHandler.UIA_IsGridItemPatternAvailablePropertyId: 'grid item pattern',
UIAHandler.UIA_IsGridPatternAvailablePropertyId: 'grid pattern',
UIAHandler.UIA_IsInvokePatternAvailablePropertyId: 'invoke pattern',
UIAHandler.UIA_IsItemContainerPatternAvailablePropertyId: 'item container pattern',
UIAHandler.UIA_IsLegacyIAccessiblePatternAvailablePropertyId: 'legacy IAccessible pattern',
UIAHandler.UIA_IsMultipleViewPatternAvailablePropertyId: 'multiple view pattern',
UIAHandler.UIA_IsObjectModelPatternAvailablePropertyId: 'object model pattern',
UIAHandler.UIA_IsRangeValuePatternAvailablePropertyId: 'range value pattern',
UIAHandler.UIA_IsScrollItemPatternAvailablePropertyId: 'scroll item pattern',
UIAHandler.UIA_IsScrollPatternAvailablePropertyId: 'scroll pattern',
UIAHandler.UIA_IsSelectionItemPatternAvailablePropertyId: 'selection item pattern',
UIAHandler.UIA_IsSelectionPatternAvailablePropertyId: 'selection pattern',
UIAHandler.UIA_IsSpreadsheetItemPatternAvailablePropertyId: 'spread sheet item pattern',
UIAHandler.UIA_IsSpreadsheetPatternAvailablePropertyId: 'spread sheet pattern',
UIAHandler.UIA_IsStylesPatternAvailablePropertyId: 'style pattern',
UIAHandler.UIA_IsSynchronizedInputPatternAvailablePropertyId: 'Synchronized input pattern',
UIAHandler.UIA_IsTableItemPatternAvailablePropertyId: 'table item patern',
UIAHandler.UIA_IsTablePatternAvailablePropertyId: 'table pattern',
UIAHandler.UIA_IsTextChildPatternAvailablePropertyId: 'text child pattern',
UIAHandler.UIA_IsTextEditPatternAvailablePropertyId: 'text edit pattern',
UIAHandler.UIA_IsTextPattern2AvailablePropertyId: 'text pattern 2',
UIAHandler.UIA_IsTextPatternAvailablePropertyId: 'text pattern',
UIAHandler.UIA_IsTogglePatternAvailablePropertyId: 'toggle pattern',
UIAHandler.UIA_IsTransformPattern2AvailablePropertyId: 'transform pattern 2',
UIAHandler.UIA_IsTransformPatternAvailablePropertyId: 'transform pattern',
UIAHandler.UIA_IsValuePatternAvailablePropertyId: 'value pattern',
UIAHandler.UIA_IsVirtualizedItemPatternAvailablePropertyId: 'virtualized item pattern',
UIAHandler.UIA_IsWindowPatternAvailablePropertyId: 'window pattern'
}
l = list()
nav = api.getNavigatorObject()
if not isinstance(nav, UIA):
ui.message('the current navigator object is not a uia object.')
return
else:
for p in uiapatternstonames.keys():
result = False
try:
result = nav.UIAElement.GetCurrentPropertyValue(p)
except:
pass
if result:
l.append(uiapatternstonames[p])
str = ', '.join(l)
if str:
log.info('supported patterns for navigator object: '+str)
ui.message(str)

@LeonarddeR
Copy link
Collaborator

I came across this and really find this interesting. @michaelDCurran, @dkager, @josephsl: What do you think? If you agree with the approach used here, I'd be happy to create a pr with this functionality integrated into the developer info.

@josephsl
Copy link
Collaborator

josephsl commented Feb 9, 2018 via email

@LeonarddeR
Copy link
Collaborator

LeonarddeR commented Feb 10, 2018 via email

@LeonarddeR
Copy link
Collaborator

Here is a branch that adds the available patterns to the developer info:
https://github.com/BabbageCom/nvda/tree/availableUIAPatterns

@josephsl: Would you like to take a first look at it? This implementation should be future proof, I'm not sure whether it is past proof though. For example, I'm not sure what _prefetchUIACacheForPropertyIDs does with property ids that are unavailable on a system. May be its just a piece of obtimisation that is not necessary at all.

@josephsl
Copy link
Collaborator

josephsl commented Feb 10, 2018 via email

@josephsl
Copy link
Collaborator

Hi,

Testing shows it won't work on versions earlier than Windows 10, as some UIA patterns were introduced in later Windows releases. One way to get around this is to wrap the appendProperty function (line 715) with a try/except block that catches COMError and skip over that when this happens.

Thanks.

@LeonarddeR
Copy link
Collaborator

LeonarddeR commented Feb 12, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants