Beispiel #1
0
	def _get__UIAControl(self):
		if UIAHandler.handler and self.role==controlTypes.ROLE_EDITABLETEXT and controlTypes.STATE_FOCUSED in self.states:
			e=UIAHandler.handler.clientObject.getFocusedElementBuildCache(UIAHandler.handler.baseCacheRequest)
			obj=UIA(UIAElement=e)
			if isinstance(obj,EditableTextWithoutAutoSelectDetection):
				obj.parent=self.parent
				obj.TextInfo=UIAMSHTMLTextInfo
				self._UIAControl=obj
				return obj
Beispiel #2
0
	def _get__UIAControl(self):
		if UIAHandler.handler and self.role==controlTypes.ROLE_EDITABLETEXT and controlTypes.STATE_FOCUSED in self.states:
			e=UIAHandler.handler.clientObject.getFocusedElementBuildCache(UIAHandler.handler.baseCacheRequest)
			obj=UIA(UIAElement=e)
			if isinstance(obj,EditableTextWithoutAutoSelectDetection):
				obj.parent=self.parent
				obj.TextInfo=UIAMSHTMLTextInfo
				self._UIAControl=obj
				return obj
Beispiel #3
0
	def event_gainFocus(self):
		# #3834: UIA has a much better implementation for rows, so use it if available.
		if self.appModule.outlookVersion<14 or not UIAHandler.handler:
			return super(SuperGridClient2010,self).event_gainFocus()
		try:
			kwargs = {}
			UIA.kwargsFromSuper(kwargs, relation="focus")
			obj=UIA(**kwargs)
		except:
			log.debugWarning("Retrieving UIA focus failed", exc_info=True)
			return super(SuperGridClient2010,self).event_gainFocus()
		if not isinstance(obj,UIAGridRow):
			return super(SuperGridClient2010,self).event_gainFocus()
		obj.parent=self.parent
		eventHandler.executeEvent("gainFocus",obj)
Beispiel #4
0
	def event_gainFocus(self):
		# #3834: UIA has a much better implementation for rows, so use it if available.
		if self.appModule.outlookVersion<14 or not UIAHandler.handler:
			return super(SuperGridClient2010,self).event_gainFocus()
		try:
			kwargs = {}
			UIA.kwargsFromSuper(kwargs, relation="focus", ignoreNonNativeElementsWithFocus=False)
			obj = UIA(**kwargs)
		except Exception:
			log.error("Retrieving UIA focus failed", exc_info=True)
			return super(SuperGridClient2010,self).event_gainFocus()
		if not isinstance(obj,UIAGridRow):
			return super(SuperGridClient2010,self).event_gainFocus()
		obj.parent=self.parent
		eventHandler.executeEvent("gainFocus",obj)
def getWExplorerStatusBarText(foreground):
    clientObject = UIAHandler.handler.clientObject
    foregroundElement = foreground.UIAElement
    element = foregroundElement.BuildUpdatedCache(
        UIAHandler.handler.baseCacheRequest)
    element = element.FindFirstBuildCache(
        UIAHandler.TreeScope_Descendants,
        clientObject.CreatePropertyCondition(
            UIAHandler.UIA_ControlTypePropertyId,
            UIAHandler.UIA_StatusBarControlTypeId),
        UIAHandler.handler.baseCacheRequest)
    if not element:
        return ""
    o = UIA(UIAElement=element)
    return o.getChild(1).firstChild.name
	def _getColumnContent(self, column):
		children = UIA._get_children(self)
		try:
			return children[column - 1].firstChild.name
		except Exception as e:
			log.debug(e)
		return ""
Beispiel #7
0
	def event_UIA_notification(self, obj, nextHandler, displayString=None, **kwargs):
		# For some reason Cortana fires this event whenever user types and an answer is received.
		# Results are displayed inside a list.
		# Thus respond to both and see what should be announced.
		if displayString != "Cortana message received.": return
		# Version 1.1910 (beta) changed UIA tree for responses list.
		# 1.1911 (beta) and version 2 changed the tree yet again.
		# Thankfully, Cortana's response is part of a grouping object.
		# As long as conversation list uses the same UIA automation ID, traversal will work across versions (code credit: Abdel)
		clientObject = UIAHandler.handler.clientObject
		condition = clientObject.CreatePropertyCondition(UIAHandler.UIA_AutomationIdPropertyId, "ConversationList")
		cortanaWindow = clientObject.ElementFromHandleBuildCache(api.getForegroundObject().windowHandle, UIAHandler.handler.baseCacheRequest)
		# Instantiate UIA object directly.
		responses = UIA(UIAElement=cortanaWindow.FindFirstBuildCache(UIAHandler.TreeScope_Descendants, condition, UIAHandler.handler.baseCacheRequest))
		try:
			cortanaResponse = responses.children[-1]
			if cortanaResponse.name.startswith("Cortana") and cortanaResponse.simpleFirstChild.role == controlTypes.ROLE_GROUPING:
				cortanaResponse = cortanaResponse.simpleFirstChild.firstChild
				# When searching through Bing, summary text shows up.
				if cortanaResponse.childCount > 1:
					cortanaResponse = ", ".join([response.name for response in cortanaResponse.children])
				else: cortanaResponse = cortanaResponse.name
		except IndexError:
			cortanaResponse = ""
		if cortanaResponse != self._cortanaResponse:
			try:
				ui.message(cortanaResponse)
				self._cortanaResponse = cortanaResponse
			except (IndexError, TypeError):
				# IndexError deals with multi-part mesage, while TypeError deals with a list item with users's message on it. Skip them.
				pass
	def _getColumnLocation(self,column):
		if column < 1 or column > self.childCount:
			return None
		child = None
		try:
			child = UIA._get_children(self)[column - 1].firstChild
		except Exception as e:
			log.debug(e)
		if not child:
			return None
		return child.location
Beispiel #9
0
	def _get_focusRedirect(self):
		if self.role==controlTypes.ROLE_UNKNOWN:
			# The control is inaccessible, try several times to find the CellEdit UIA element with focus and use that instead.
			for count in xrange(10):
				if count>=1:
					api.processPendingEvents(processEventQueue=False)
					if eventHandler.isPendingEvents("gainFocus"):
						return
					time.sleep(0.05)
				e=UIAHandler.handler.lastFocusedUIAElement
				if e and e.cachedAutomationID=="CellEdit":
					obj=UIA(UIAElement=e)
					oldFocus=api.getFocusObject()
					if isinstance(oldFocus,ExcelCell):
						# Set the edit control's parent as the cell that previously had focus. I.e. the cell being edited.
						# otherwise a whole bunch of UIA focus ancestors for the edit control will be reported.
						obj.parent=oldFocus
					# Cache this for as long as this object exists.
					self.focusRedirect=obj
					return obj
Beispiel #10
0
 def _get_focusRedirect(self):
     if self.role == controlTypes.ROLE_UNKNOWN:
         # The control is inaccessible, try several times to find the CellEdit UIA element with focus and use that instead.
         for count in range(10):
             if count >= 1:
                 api.processPendingEvents(processEventQueue=False)
                 if eventHandler.isPendingEvents("gainFocus"):
                     return
                 time.sleep(0.05)
             e = UIAHandler.handler.lastFocusedUIAElement
             if e and e.cachedAutomationID == "CellEdit":
                 obj = UIA(UIAElement=e)
                 oldFocus = api.getFocusObject()
                 if isinstance(oldFocus, ExcelCell):
                     # Set the edit control's parent as the cell that previously had focus. I.e. the cell being edited.
                     # otherwise a whole bunch of UIA focus ancestors for the edit control will be reported.
                     obj.parent = oldFocus
                 # Cache this for as long as this object exists.
                 self.focusRedirect = obj
                 return obj
Beispiel #11
0
 def _get_statusBar(self):
     foreground = api.getForegroundObject()
     if not isinstance(
             foreground,
             UIA) or not foreground.windowClassName == "CabinetWClass":
         # This is not the file explorer window. Resort to standard behavior.
         raise NotImplementedError
     import UIAHandler
     clientObject = UIAHandler.handler.clientObject
     condition = clientObject.createPropertyCondition(
         UIAHandler.UIA_ControlTypePropertyId,
         UIAHandler.UIA_StatusBarControlTypeId)
     walker = clientObject.createTreeWalker(condition)
     try:
         element = walker.getFirstChildElement(foreground.UIAElement)
     except COMError:
         # We could not find the expected object. Resort to standard behavior.
         raise NotImplementedError()
     element = element.buildUpdatedCache(
         UIAHandler.handler.baseCacheRequest)
     statusBar = UIA(UIAElement=element)
     return statusBar
Beispiel #12
0
	def obj(self):
		if self._UIAElement:
			UIAElement=self._UIAElement.buildUpdatedCache(UIAHandler.handler.baseCacheRequest)
			return UIA(UIAElement=UIAElement)
		return self.textInfo.NVDAObjectAtStart
	def _get_childCount(self):
		return len(UIA._get_children(self))