def event_liveRegionChange(self, obj, nextHandler):
if isinstance(obj, UIA):
# Accessibility message alerts.
# For some messages, system alert event is raised along with this event, so return.
if obj.role == controlTypes.ROLE_ALERT and obj.UIAElement.cachedAutomationID == "a11y-announcements-message":
return
nextHandler()
# For message alerts, system alert and live region changed are fired at the same time.
python类message()的实例源码
def event_UIA_systemAlert(self, obj, nextHandler):
if isinstance(obj, UIA):
if obj.role == controlTypes.ROLE_ALERT and obj.UIAElement.cachedAutomationID == "a11y-announcements-message":
# Mick Curran says use last child in case a series of live texts are part of this control.
ui.message(obj.lastChild.name)
nextHandler()
windowsinternal_composableshell_experiences_textinput_inputapp.py 文件源码
项目:wintenApps
作者: josephsl
项目源码
文件源码
阅读 25
收藏 0
点赞 0
评论 0
def event_UIA_elementSelected(self, obj, nextHandler):
# #7273: When this is fired on categories, the first emoji from the new category is selected but not announced.
# Therefore, move the navigator object to that item if possible.
# However, in recent builds, name change event is also fired.
# For consistent experience, report the new category first by traversing through controls.
speech.cancelSpeech()
# And no, if running on build 17040 and if this is typing suggestion, do not announce candidate window changes, as it is duplicate announcement and is anoying.
if obj.UIAElement.cachedAutomationID == "IME_Candidate_Window": return
candidate = obj
if obj.UIAElement.cachedClassName == "ListViewItem":
# The difference between emoji panel and suggestions list is absence of categories/emoji separation.
# If dealing with keyboard entry suggestions (build 17040 and later), return immediately.
candidate = obj.parent.previous
if candidate is None:
ui.message(obj.name)
nextHandler()
return
ui.message(candidate.name)
obj = candidate.firstChild
if obj is not None:
api.setNavigatorObject(obj)
obj.reportFocus()
braille.handler.message(braille.getBrailleTextForProperties(name=obj.name, role=obj.role, positionInfo=obj.positionInfo))
else:
# Translators: presented when there is no emoji when searching for one in Windows 10 Fall Creators Update and later.
ui.message(_("No emoji"))
nextHandler()
def script_previousLine(self, gesture):
if self.curLine > 0:
self.curLine -=1
ui.message(self.lines[self.curLine])
else:
# Translators: Message presented when no more weather data is available for the current item.
ui.message(_("No more weather data for this item."))
wx.Bell()
def event_nameChange(self, obj, nextHandler):
if isinstance(obj, UIA):
# #18: Announce street side changes as one uses the keyboard.
if obj.UIAElement.cachedAutomationID == "StreetsideAddressTextBlock":
ui.message(obj.name)
nextHandler()
# Yet again, live region change fires even if no text has changed.
def event_liveRegionChange(self, obj, nextHandler):
if isinstance(obj, UIA):
if obj.parent.UIAElement.cachedAutomationID == "MapControl" and obj.name != self.liveText:
self.liveText = obj.name
ui.message(obj.name)
# And no, never call next handler.
def event_nameChange(self, obj, nextHandler):
# NVDA, can you act as a mouthpiece for Cortana?
if isinstance(obj, UIA) and isinstance(obj.next, UIA) and obj.next.UIAElement.cachedAutomationID != "SpeechButton" and obj.name != self.cortanaResponseCache:
element = obj.UIAElement
# There are two Cortana response lines. Usually line 2 is more reliable.
# However, Redstone seems to favor line 1 better.
# A specific automation ID is used for reminders and others.
if element.cachedAutomationID in ("SpeechContentLabel", "WeSaidTextBlock", "GreetingLine1"):
ui.message(obj.name)
self.cortanaResponseCache = obj.name
nextHandler()
def event_liveRegionChange(self, obj, nextHandler):
if isinstance(obj, UIA) and obj.UIAElement.cachedAutomationID == "_progressText":
if obj.name != self._appInstallProgress:
self._appInstallProgress = obj.name
# Don't forget to announce product title.
productTitle = obj.parent.previous
# Since March 2017 update, it is no longer the product name, but a progress button.
if productTitle and productTitle.role == controlTypes.ROLE_BUTTON:
# But since September 2017 update, the title is next door.
possibleProductTitle = productTitle.parent.previous
productTitle = productTitle.previous if possibleProductTitle is None else productTitle.parent.previous
if productTitle and isinstance(productTitle, UIA) and productTitle.UIAElement.cachedAutomationID == "_productTitle":
ui.message(" ".join([productTitle.name, obj.name]))
return
nextHandler()
def reportFocus(self):
# Skype message/channel info and other extraneous text should not be announced.
# Credit: Derek Riemer
# But save the old name just in case it needs to be referred back to.
self._message = self.name
self.name = self.getShortenedMessage()
super(SkypeMessage, self).reportFocus()
def script_showMessageLongDesc(self, gesture):
ui.message(self._message)
# Translators: the description for the showMessageLongDesc script on Skype for Windows 10.
def event_nameChange(self, obj, nextHandler):
# In recent versions, live region change event is used instead, so don't announce messages with this method.
if isinstance(obj, UIA):
uiElement = obj.UIAElement
if uiElement.cachedClassName == "TextBlock" and obj.next is not None:
# Announce typing indicator (same as Skype for Desktop).
nextElement = obj.next.UIAElement
# Make sure to catch all possible UI placement changes between Skype UWP releases.
if nextElement.cachedAutomationID in ("ChatEditBox", "ChatTranslationSettings"):
# Translators: Presented when someone stops typing in Skype app (same as Skype for Desktop).
ui.message(obj.name if obj.name != "" else _("Typing stopped"))
nextHandler()
# The live region changed event for messages has no automation ID whatsoever.
# Unfortunately, Skype message fires name change, so be sure to perform one or the other.
def event_liveRegionChange(self, obj, nextHandler):
if isinstance(obj, UIA):
uiaElement = obj.UIAElement
if not uiaElement.cachedAutomationID and uiaElement.cachedClassName == "TextBlock" and obj.name != self._skypeMessageCache:
ui.message(getShortenedMessage(obj.name))
self._skypeMessageCache = obj.name
return
nextHandler()
def script_moveToArea(self, gesture):
area = int(gesture.displayName.split("+")[-1])
# However, since March 2017, areas received keyboard shortcuts, such as Alt+2 for contacts list.
if self.productVersion >= "11.13.133.0" and area < 4:
gesture.send()
return
element = self.locateElement(self.moveTo[area][0])
if element is None:
ui.message(self.moveTo[area][1])
return
element.setFocus()
return
def event_nameChange(self, obj, nextHandler):
ui.message(obj.name)
nextHandler()
def script_reportStatusLine(self, gesture):
#it seems that the status bar is the last child of the forground object
#so, get it from there
obj = api.getForegroundObject().lastChild
found=False
if obj and obj.role == controlTypes.ROLE_STATUSBAR:
text = api.getStatusBarText(obj)
api.setNavigatorObject(obj)
found=True
else:
info=api.getForegroundObject().flatReviewPosition
if info:
info.expand(textInfos.UNIT_STORY)
info.collapse(True)
info.expand(textInfos.UNIT_LINE)
text=info.text
info.collapse()
api.setReviewPosition(info)
found=True
if not found:
# Translators: Reported when there is no status line for the current program or window.
ui.message(_("No status line found"))
return
if scriptHandler.getLastScriptRepeatCount()==0:
ui.message(text)
else:
speech.speakSpelling(text)
# Translators: Input help mode message for report status line text command.
def script_expand(self, gesture):
if controlTypes.STATE_COLLAPSED in self.states:
#translators: a message indecating that a tree view item in watch / locals /... tool window has been expanded
ui.message(_("expanded"))
gesture.send()
def script_collapse(self, gesture):
if controlTypes.STATE_EXPANDED in self.states:
#translators: a message indecating that a tree view item in watch / locals /... tool window has been collapsed
ui.message(_("collapsed"))
gesture.send()
def script_onSizeChange(self, gesture):
gesture.send()
#get the position from the status bar
obj = api.getForegroundObject().lastChild
text = obj.children[2].name
width = re.match(REG_SPLIT_LOCATION_TEXT, text).group(3)
hight = re.match(REG_SPLIT_LOCATION_TEXT, text).group(4)
#translators: the width and the hight of a UI element in windows forms designer
msg = _("width: %s hight: %s" %(width, hight))
ui.message(msg)
def script_breakpointToggle(self,gesture) :
colors = self._hasBackground([RGB_BP])
if(colors[RGB_BP]) :
ui.message(_("Breakpoint off"))
else :
ui.message(_("Breakpoint on"))
gesture.send()
def script_errorReport(self,gesture) :
gesture.send()
colors = self._hasBackground([RGB_ERROR,RGB_WARN])
if(colors[RGB_ERROR]) :
braille.handler.message(_("\t\t error %% error"))
self.appModule.play_error()
elif(colors[RGB_WARN]) :
braille.handler.message(_("\t\t warning %% warning"))
self.appModule.play_warning()
globalCommands.commands.script_reportCurrentLine(gesture)