def IUIAutomationPropertyChangedEventHandler_HandlePropertyChangedEvent(self,sender,propertyId,newValue):
		# #3867: For now manually force this VARIANT type to empty to get around a nasty double free in comtypes/ctypes.
		# We also don't use the value in this callback.
		newValue.vt=VT_EMPTY
		if not self.MTAThreadInitEvent.isSet():
			# UIAHandler hasn't finished initialising yet, so just ignore this event.
			return
		NVDAEventName=UIAPropertyIdsToNVDAEventNames.get(propertyId,None)
		if not NVDAEventName:
			return
		if not self.isNativeUIAElement(sender):
			return
		try:
			window=sender.cachedNativeWindowHandle
		except COMError:
			window=None
		if window and not eventHandler.shouldAcceptEvent(NVDAEventName,windowHandle=window):
			return
		import NVDAObjects.UIA
		obj=NVDAObjects.UIA.UIA(UIAElement=sender)
		if not obj:
			return
		focus=api.getFocusObject()
		if obj==focus:
			obj=focus
		eventHandler.queueEvent(NVDAEventName,obj)
示例#2
0
def event_gainFocus(vmID,accContext):
	tempContext=accContext
	while tempContext:
		try:
			tempContext=bridgeDll.getActiveDescendent(vmID,tempContext)
		except:
			tempContext=None
		try:
			depth=bridgeDll.getObjectDepth(vmID,tempContext)
		except:
			depth=-1
		if tempContext and (depth<=0 or bridgeDll.isSameObject(vmID,accContext,tempContext)):
			tempContext=None
		if tempContext:
			bridgeDll.releaseJavaObject(vmID,accContext)
			accContext=tempContext
	jabContext=JABContext(vmID=vmID,accContext=accContext)
	if not winUser.isDescendantWindow(winUser.getForegroundWindow(),jabContext.hwnd):
		return
	focus=eventHandler.lastQueuedFocusObject
	if (isinstance(focus,NVDAObjects.JAB.JAB) and focus.jabContext==jabContext):
		return 
	obj=NVDAObjects.JAB.JAB(jabContext=jabContext)
	if obj.role==controlTypes.ROLE_UNKNOWN:
		return
	eventHandler.queueEvent("gainFocus",obj)
示例#3
0
文件: NVDAHelper.py 项目: bramd/nvda
def nvdaControllerInternal_drawFocusRectNotify(hwnd, left, top, right, bottom):
	import eventHandler
	from NVDAObjects.window import Window
	focus=api.getFocusObject()
	if isinstance(focus,Window) and hwnd==focus.windowHandle:
		eventHandler.queueEvent("displayModel_drawFocusRectNotify",focus,rect=(left,top,right,bottom))
	return 0;
def processShowWinEvent(window,objectID,childID):
	className=winUser.getClassName(window)
	#For now we only support 'show' event for tooltips as otherwize we get flooded
	if className=="tooltips_class32" and objectID==winUser.OBJID_CLIENT:
		NVDAEvent=winEventToNVDAEvent(winUser.EVENT_OBJECT_SHOW,window,objectID,childID)
		if NVDAEvent:
			eventHandler.queueEvent(*NVDAEvent)
def processShowWinEvent(window,objectID,childID):
	className=winUser.getClassName(window)
	#For now we only support 'show' event for tooltips, IMM candidates and notification bars  as otherwize we get flooded
	if className in ("Frame Notification Bar","tooltips_class32","mscandui21.candidate","mscandui40.candidate","MSCandUIWindow_Candidate") and objectID==winUser.OBJID_CLIENT:
		NVDAEvent=winEventToNVDAEvent(winUser.EVENT_OBJECT_SHOW,window,objectID,childID)
		if NVDAEvent:
			eventHandler.queueEvent(*NVDAEvent)
示例#6
0
	def handleSelectionChange(self):
		"""Pushes focus to the newly selected object."""
		obj=self.selection
		if not obj:
			obj=DocumentWindow(windowHandle=self.windowHandle)
		if obj and obj!=api.getFocusObject() and not eventHandler.isPendingEvents("gainFocus"):
			eventHandler.queueEvent("gainFocus",obj)
示例#7
0
def processShowWinEvent(window,objectID,childID):
	# eventHandler.shouldAcceptEvent only accepts show events for a few specific cases.
	# Narrow this further to only accept events for clients or custom objects.
	if objectID==winUser.OBJID_CLIENT or objectID>0:
		NVDAEvent=winEventToNVDAEvent(winUser.EVENT_OBJECT_SHOW,window,objectID,childID)
		if NVDAEvent:
			eventHandler.queueEvent(*NVDAEvent)
示例#8
0
	def IUIAutomationEventHandler_HandleAutomationEvent(self,sender,eventID):
		if not self.MTAThreadInitEvent.isSet():
			# UIAHandler hasn't finished initialising yet, so just ignore this event.
			return
		if eventID==UIA_MenuOpenedEventId and eventHandler.isPendingEvents("gainFocus"):
			# We don't need the menuOpened event if focus has been fired,
			# as focus should be more correct.
			return
		NVDAEventName=UIAEventIdsToNVDAEventNames.get(eventID,None)
		if not NVDAEventName:
			return
		if not self.isNativeUIAElement(sender):
			return
		window=self.getNearestWindowHandle(sender)
		if window and not eventHandler.shouldAcceptEvent(NVDAEventName,windowHandle=window):
			return
		import NVDAObjects.UIA
		obj=NVDAObjects.UIA.UIA(UIAElement=sender)
		if (
			not obj
			or (NVDAEventName=="gainFocus" and not obj.shouldAllowUIAFocusEvent)
			or (NVDAEventName=="liveRegionChange" and not obj._shouldAllowUIALiveRegionChangeEvent)
		):
			return
		focus=api.getFocusObject()
		if obj==focus:
			obj=focus
		eventHandler.queueEvent(NVDAEventName,obj)
	def elementChanged( self , ElementID ,arg1,arg2):
		selectedChartElement = None
		if ElementID == xlAxis:
			selectedChartElement = ExcelChartElementAxis( windowHandle= self.windowHandle , excelChartObject= self.excelChartObject  , elementID=ElementID  , arg1=arg1 , arg2=arg2 )
		elif ElementID == xlAxisTitle:  
			selectedChartElement = ExcelChartElementAxisTitle( windowHandle= self.windowHandle , excelChartObject= self.excelChartObject  , elementID=ElementID  , arg1=arg1 , arg2=arg2 )
		elif ElementID == xlSeries:
			selectedChartElement = ExcelChartElementSeries( windowHandle= self.windowHandle , excelChartObject= self.excelChartObject  , elementID=ElementID  , arg1=arg1 , arg2=arg2 )
		elif ElementID == xlTrendline:
			selectedChartElement = ExcelChartElementTrendline( windowHandle= self.windowHandle , excelChartObject= self.excelChartObject  , elementID=ElementID  , arg1=arg1 , arg2=arg2 )
		elif ElementID == xlChartTitle:
			selectedChartElement = ExcelChartElementChartTitle( windowHandle= self.windowHandle , excelChartObject= self.excelChartObject  , elementID=ElementID  , arg1=arg1 , arg2=arg2 )
		elif ElementID == xlChartArea:
			selectedChartElement = ExcelChartElementChartArea( windowHandle= self.windowHandle , excelChartObject= self.excelChartObject  , elementID=ElementID  , arg1=arg1 , arg2=arg2 )
		elif ElementID == xlPlotArea:
			selectedChartElement = ExcelChartElementPlotArea( windowHandle= self.windowHandle , excelChartObject= self.excelChartObject  , elementID=ElementID  , arg1=arg1 , arg2=arg2 )
		elif ElementID == xlLegend:
			selectedChartElement = ExcelChartElementLegend( windowHandle= self.windowHandle , excelChartObject= self.excelChartObject  , elementID=ElementID  , arg1=arg1 , arg2=arg2 )
		elif ElementID == xlLegendEntry:
			selectedChartElement = ExcelChartElementLegendEntry( windowHandle= self.windowHandle , excelChartObject= self.excelChartObject  , elementID=ElementID  , arg1=arg1 , arg2=arg2 )
		elif ElementID == xlLegendKey:
			selectedChartElement = ExcelChartElementLegendKey( windowHandle= self.windowHandle , excelChartObject= self.excelChartObject  , elementID=ElementID  , arg1=arg1 , arg2=arg2 )
		else:
			selectedChartElement = ExcelChartElementBase( windowHandle= self.windowHandle , excelChartObject= self.excelChartObject  , elementID=ElementID  , arg1=arg1 , arg2=arg2 )

		if selectedChartElement :
			selectedChartElement.parent = self
			selectedChartElement.previous = None
			selectedChartElement.next = None
			eventHandler.queueEvent("gainFocus", selectedChartElement )
示例#10
0
def processGenericWinEvent(eventID,window,objectID,childID):
	"""Converts the win event to an NVDA event,
	Checks to see if this NVDAObject  equals the current focus.
	If all goes well, then the event is queued and we return True
	@param eventID: a win event ID (type)
	@type eventID: integer
	@param window: a win event's window handle
	@type window: integer
	@param objectID: a win event's object ID
	@type objectID: integer
	@param childID: a win event's child ID
	@type childID: integer
	@returns: True if the event was processed, False otherwise.
	@rtype: boolean
	"""
	#Notify appModuleHandler of this new window
	appModuleHandler.update(winUser.getWindowThreadProcessID(window)[0])
	#Handle particular events for the special MSAA caret object just as if they were for the focus object
	focus=eventHandler.lastQueuedFocusObject
	if focus and objectID==winUser.OBJID_CARET and eventID in (winUser.EVENT_OBJECT_LOCATIONCHANGE,winUser.EVENT_OBJECT_SHOW):
		NVDAEvent=("caret",focus)
	else:
		NVDAEvent=winEventToNVDAEvent(eventID,window,objectID,childID)
		if not NVDAEvent:
			return False
	if NVDAEvent[0]=="nameChange" and objectID==winUser.OBJID_CURSOR:
		mouseHandler.updateMouseShape(NVDAEvent[1].name)
		return
	if NVDAEvent[1]==focus:
		NVDAEvent=(NVDAEvent[0],focus)
	eventHandler.queueEvent(*NVDAEvent)
	return True
示例#11
0
	def event_valueChange(self):
		if self.event_childID==0 and self.event_objectID == winUser.OBJID_CLIENT and winUser.isDescendantWindow(winUser.getForegroundWindow(),self.windowHandle):
			# Acrobat has indicated that a page has died and been replaced by a new one.
			# The new page has the same event params, so we must bypass NVDA's IAccessible caching.
			obj = getNVDAObjectFromEvent(self.windowHandle, -4, 0)
			if not obj:
				return
			eventHandler.queueEvent("gainFocus",obj)
示例#12
0
	def event_gainFocus(self):
		"""Bounces focus to the currently selected slide, shape or Text frame."""
		obj=self.selection
		if obj:
			eventHandler.queueEvent("focusEntered",self)
			eventHandler.queueEvent("gainFocus",obj)
		else:
			super(DocumentWindow,self).event_gainFocus()
示例#13
0
	def setFocus(self):
		ti = self.parent.treeInterceptor
		if isinstance(ti, browseMode.BrowseModeDocumentTreeInterceptor):
			# Normally, when entering browse mode from a descendant (e.g. dialog),
			# we want the cursor to move to the focus (#3145).
			# However, we don't want this for recognition results, as these aren't focusable.
			ti._enteringFromOutside = True
		# This might get called from a background thread and all NVDA events must run in the main thread.
		eventHandler.queueEvent("gainFocus", self)
示例#14
0
文件: emule.py 项目: nvdaes/emule
	def script_toolBar(self, gesture):
		obj = self.getToolBar()
		if obj is not None:
			if obj != api.getMouseObject():
				api.moveMouseToNVDAObject(obj)
				api.setMouseObject(obj)
			if controlTypes.State.FOCUSED not in obj.states:
				obj.setFocus()
			eventHandler.queueEvent("gainFocus", obj)
	def script_reportParameterInfo(self, gesture):
		# get the parameter info object
		try:
			obj = api.getForegroundObject().firstChild.firstChild
		except:
			return
		if obj.role == controlTypes.ROLE_TOOLTIP:
			# emulate an alert event for this object
			eventHandler.queueEvent("alert", obj)
示例#16
0
	def event_gainFocus(self):
		child=self.selection
		if not child and self.childCount>0:
			child=self.children[0]
		if child:
			eventHandler.queueEvent("focusEntered",self)
			eventHandler.queueEvent("gainFocus",child)
		else:
			super(ExcelDropdown,self).event_gainFocus()
示例#17
0
	def event_gainFocus(self):
		if eventHandler.isPendingEvents("gainFocus"):
			return
		super(JAB,self).event_gainFocus()
		if eventHandler.isPendingEvents("gainFocus"):
			return
		activeDescendant=self.activeDescendant
		if activeDescendant:
			eventHandler.queueEvent("gainFocus",activeDescendant)
示例#18
0
文件: __init__.py 项目: hss16/nvda
 def event_gainFocus(self):
     if eventHandler.isPendingEvents("gainFocus"):
         return
     super(JAB, self).event_gainFocus()
     if eventHandler.isPendingEvents("gainFocus"):
         return
     activeDescendant = self.activeDescendant
     if activeDescendant:
         eventHandler.queueEvent("gainFocus", activeDescendant)
def nvdaControllerInternal_drawFocusRectNotify(hwnd, left, top, right, bottom):
    import eventHandler
    from NVDAObjects.window import Window
    focus = api.getFocusObject()
    if isinstance(focus, Window) and hwnd == focus.windowHandle:
        eventHandler.queueEvent("displayModel_drawFocusRectNotify",
                                focus,
                                rect=(left, top, right, bottom))
    return 0
示例#20
0
文件: excel.py 项目: lpintes/NVDA
	def event_gainFocus(self):
		child=self.selection
		if not child and self.childCount>0:
			child=self.children[0]
		if child:
			eventHandler.queueEvent("focusEntered",self)
			eventHandler.queueEvent("gainFocus",child)
		else:
			super(ExcelDropdown,self).event_gainFocus()
示例#21
0
 def IUIAutomationFocusChangedEventHandler_HandleFocusChangedEvent(
         self, sender):
     if not self.MTAThreadInitEvent.isSet():
         # UIAHandler hasn't finished initialising yet, so just ignore this event.
         if _isDebug():
             log.debug(
                 "HandleFocusChangedEvent: event received while not fully initialized"
             )
         return
     self.lastFocusedUIAElement = sender
     if not self.isNativeUIAElement(sender):
         if _isDebug():
             log.debug(
                 "HandleFocusChangedEvent: Ignoring for non native element")
         return
     import NVDAObjects.UIA
     if isinstance(eventHandler.lastQueuedFocusObject, NVDAObjects.UIA.UIA):
         lastFocus = eventHandler.lastQueuedFocusObject.UIAElement
         # Ignore duplicate focus events.
         # It seems that it is possible for compareElements to return True, even though the objects are different.
         # Therefore, don't ignore the event if the last focus object has lost its hasKeyboardFocus state.
         try:
             if (self.clientObject.compareElements(sender, lastFocus)
                     and lastFocus.currentHasKeyboardFocus):
                 if _isDebug():
                     log.debugWarning(
                         "HandleFocusChangedEvent: Ignoring duplicate focus event"
                     )
                 return
         except COMError:
             if _isDebug():
                 log.debugWarning(
                     "HandleFocusChangedEvent: Couldn't check for duplicate focus event",
                     exc_info=True)
     window = self.getNearestWindowHandle(sender)
     if window and not eventHandler.shouldAcceptEvent("gainFocus",
                                                      windowHandle=window):
         if _isDebug():
             log.debug(
                 "HandleFocusChangedEvent: Ignoring for shouldAcceptEvent=False"
             )
         return
     try:
         obj = NVDAObjects.UIA.UIA(UIAElement=sender)
     except Exception:
         if _isDebug():
             log.debugWarning(
                 "HandleFocusChangedEvent: Exception while creating object",
                 exc_info=True)
         return
     if not obj or not obj.shouldAllowUIAFocusEvent:
         if _isDebug():
             log.debug(
                 "HandleFocusChangedEvent: Ignoring because no object or ignored by object itself"
             )
         return
     eventHandler.queueEvent("gainFocus", obj)
示例#22
0
 def script_activate(self, gesture):
     try:
         self.doAction()
         if self.windowControlID == ctrlIdsDic["favButton"]:
             eventHandler.queueEvent("gainFocus", self)
             time.sleep(0.1)
             api.processPendingEvents()
             KeyboardInputGesture.fromName("downArrow").send()
     except Exception:
         gesture.send()
示例#23
0
def event_valueChange(vmID,event,source,oldVal,newVal):
	jabContext=JABContext(vmID=vmID,accContext=source)
	focus=api.getFocusObject()
	if isinstance(focus, NVDAObjects.JAB.JAB) and focus.jabContext == jabContext:
		obj = focus
	else:
		obj = NVDAObjects.JAB.JAB(jabContext=jabContext)
	if obj:
		eventHandler.queueEvent("valueChange", obj)
	bridgeDll.releaseJavaObject(vmID,event)
示例#24
0
	def event_gainFocus(self):
		child = self.firstChild
		if child and controlTypes.STATE_FOCUSED in child.states and not eventHandler.isPendingEvents("gainFocus"):
			# UIA reports that focus is on the top level pane, even when it's actually on the frame below.
			# This causes us to incorrectly use UIA for the top level pane, which causes this pane to be spoken again when the focus moves.
			# Therefore, bounce the focus to the correct object.
			eventHandler.queueEvent("gainFocus", child)
			return

		return super(LogonDialog, self).event_gainFocus()
示例#25
0
	def navigateToElement(self, direction):
		if len(self.elementList) == 0: 
			ui.message(self.name)
		else:
			if self.activeElement == None: self.activeElement = self.elementList[0]
			else: 
				if direction=="previous": self.activeElement = self.activeElement.previous
				elif direction=="next": self.activeElement = self.activeElement.next
			self.activeElement.select() 
			eventHandler.queueEvent("gainFocus", self.activeElement)
示例#26
0
 def script_clickFavButton(self, gesture):
     if not self.inMainWindow():
         gesture.send()
         return
     clickButton("favButton")
     obj = api.getFocusObject()
     eventHandler.queueEvent("gainFocus", obj)
     time.sleep(0.1)
     api.processPendingEvents()
     KeyboardInputGesture.fromName("downArrow").send()
示例#27
0
	def event_gainFocus(self):
		child = self.firstChild
		if child and controlTypes.STATE_FOCUSED in child.states and not eventHandler.isPendingEvents("gainFocus"):
			# UIA reports that focus is on the top level pane, even when it's actually on the frame below.
			# This causes us to incorrectly use UIA for the top level pane, which causes this pane to be spoken again when the focus moves.
			# Therefore, bounce the focus to the correct object.
			eventHandler.queueEvent("gainFocus", child)
			return

		return super(LogonDialog, self).event_gainFocus()
示例#28
0
def event_caret(vmID, accContext, hwnd):
	jabContext = JABContext(hwnd=hwnd, vmID=vmID, accContext=accContext)
	focus = api.getFocusObject()
	if isinstance(focus, NVDAObjects.JAB.JAB) and focus.jabContext == jabContext:
		obj = focus
	else:
		obj = NVDAObjects.JAB.JAB(jabContext=jabContext)
		if not obj:
			return
	eventHandler.queueEvent("caret", obj)
示例#29
0
def event_valueChange(vmID,event,source,oldVal,newVal):
	jabContext=JABContext(vmID=vmID,accContext=source)
	focus=api.getFocusObject()
	if isinstance(focus, NVDAObjects.JAB.JAB) and focus.jabContext == jabContext:
		obj = focus
	else:
		obj = NVDAObjects.JAB.JAB(jabContext=jabContext)
	if obj:
		eventHandler.queueEvent("valueChange", obj)
	bridgeDll.releaseJavaObject(vmID,event)
示例#30
0
def event_caret(vmID, accContext, hwnd):
	jabContext = JABContext(hwnd=hwnd, vmID=vmID, accContext=accContext)
	focus = api.getFocusObject()
	if isinstance(focus, NVDAObjects.JAB.JAB) and focus.jabContext == jabContext:
		obj = focus
	else:
		obj = NVDAObjects.JAB.JAB(jabContext=jabContext)
		if not obj:
			return
	eventHandler.queueEvent("caret", obj)
示例#31
0
 def IUIAutomationPropertyChangedEventHandler_HandlePropertyChangedEvent(
         self, sender, propertyId, newValue):
     # #3867: For now manually force this VARIANT type to empty to get around a nasty double free in comtypes/ctypes.
     # We also don't use the value in this callback.
     newValue.vt = VT_EMPTY
     if not self.MTAThreadInitEvent.isSet():
         # UIAHandler hasn't finished initialising yet, so just ignore this event.
         if _isDebug():
             log.debug(
                 "HandlePropertyChangedEvent: event received while not fully initialized"
             )
         return
     NVDAEventName = UIAPropertyIdsToNVDAEventNames.get(propertyId, None)
     if not NVDAEventName:
         if _isDebug():
             log.debugWarning(
                 f"HandlePropertyChangedEvent: Don't know how to handle property {propertyId}"
             )
         return
     focus = api.getFocusObject()
     import NVDAObjects.UIA
     if (isinstance(focus, NVDAObjects.UIA.UIA) and
             self.clientObject.compareElements(focus.UIAElement, sender)):
         pass
     elif not self.isNativeUIAElement(sender):
         if _isDebug():
             log.debug(
                 f"HandlePropertyChangedEvent: Ignoring event {NVDAEventName} for non native element"
             )
         return
     window = self.getNearestWindowHandle(sender)
     if window and not eventHandler.shouldAcceptEvent(NVDAEventName,
                                                      windowHandle=window):
         if _isDebug():
             log.debug(
                 f"HandlePropertyChangedEvent: Ignoring event {NVDAEventName} for shouldAcceptEvent=False"
             )
         return
     try:
         obj = NVDAObjects.UIA.UIA(UIAElement=sender)
     except Exception:
         if _isDebug():
             log.debugWarning(
                 f"HandlePropertyChangedEvent: Exception while creating object for event {NVDAEventName}",
                 exc_info=True)
         return
     if not obj:
         if _isDebug():
             log.debug(
                 f"HandlePropertyChangedEvent: Ignoring event {NVDAEventName} because no object"
             )
         return
     if obj == focus:
         obj = focus
     eventHandler.queueEvent(NVDAEventName, obj)
示例#32
0
def event_gainFocus(vmID,accContext,hwnd):
	jabContext=JABContext(hwnd=hwnd,vmID=vmID,accContext=accContext)
	if not winUser.isDescendantWindow(winUser.getForegroundWindow(),jabContext.hwnd):
		return
	focus=eventHandler.lastQueuedFocusObject
	if (isinstance(focus,NVDAObjects.JAB.JAB) and focus.jabContext==jabContext):
		return 
	obj=NVDAObjects.JAB.JAB(jabContext=jabContext)
	if obj.role==controlTypes.ROLE_UNKNOWN:
		return
	eventHandler.queueEvent("gainFocus",obj)
示例#33
0
def event_gainFocus(vmID,accContext,hwnd):
	jabContext=JABContext(hwnd=hwnd,vmID=vmID,accContext=accContext)
	if not winUser.isDescendantWindow(winUser.getForegroundWindow(),jabContext.hwnd):
		return
	focus=eventHandler.lastQueuedFocusObject
	if (isinstance(focus,NVDAObjects.JAB.JAB) and focus.jabContext==jabContext):
		return 
	obj=NVDAObjects.JAB.JAB(jabContext=jabContext)
	if obj.role==controlTypes.ROLE_UNKNOWN:
		return
	eventHandler.queueEvent("gainFocus",obj)
示例#34
0
def processShowWinEvent(window, objectID, childID):
	if isMSAADebugLoggingEnabled():
		log.debug(
			f"Processing show winEvent: {getWinEventLogInfo(window, objectID, childID)}"
		)
	# eventHandler.shouldAcceptEvent only accepts show events for a few specific cases.
	# Narrow this further to only accept events for clients or custom objects.
	if objectID == winUser.OBJID_CLIENT or objectID > 0:
		NVDAEvent = winEventToNVDAEvent(winUser.EVENT_OBJECT_SHOW, window, objectID, childID)
		if NVDAEvent:
			eventHandler.queueEvent(*NVDAEvent)
示例#35
0
	def IUIAutomationNotificationEventHandler_HandleNotificationEvent(self,sender,NotificationKind,NotificationProcessing,displayString,activityId):
		if not self.MTAThreadInitEvent.isSet():
			# UIAHandler hasn't finished initialising yet, so just ignore this event.
			return
		import NVDAObjects.UIA
		obj=NVDAObjects.UIA.UIA(UIAElement=sender)
		if not obj:
			# Sometimes notification events can be fired on a UIAElement that has no windowHandle and does not connect through parents back to the desktop.
			# There is nothing we can do with these.
			return
		eventHandler.queueEvent("UIA_notification",obj, notificationKind=NotificationKind, notificationProcessing=NotificationProcessing, displayString=displayString, activityId=activityId)
示例#36
0
	def IUIAutomationNotificationEventHandler_HandleNotificationEvent(self,sender,NotificationKind,NotificationProcessing,displayString,activityId):
		if not self.MTAThreadInitEvent.isSet():
			# UIAHandler hasn't finished initialising yet, so just ignore this event.
			return
		import NVDAObjects.UIA
		obj=NVDAObjects.UIA.UIA(UIAElement=sender)
		if not obj:
			# Sometimes notification events can be fired on a UIAElement that has no windowHandle and does not connect through parents back to the desktop.
			# There is nothing we can do with these.
			return
		eventHandler.queueEvent("UIA_notification",obj, notificationKind=NotificationKind, notificationProcessing=NotificationProcessing, displayString=displayString, activityId=activityId)
示例#37
0
	def event_valueChange(self):
		# Acrobat has indicated that a page has died and been replaced by a new one.
		if not self.isInForeground:
			# If this isn't in the foreground, it doesn't matter,
			# as focus will be fired on the correct object when it is in the foreground again.
			return
		# The new page has the same event params, so we must bypass NVDA's IAccessible caching.
		obj = getNVDAObjectFromEvent(self.windowHandle, winUser.OBJID_CLIENT, 0)
		if not obj:
			return
		eventHandler.queueEvent("gainFocus",obj)
示例#38
0
	def event_valueChange(self):
		# Acrobat has indicated that a page has died and been replaced by a new one.
		if not self.isInForeground:
			# If this isn't in the foreground, it doesn't matter,
			# as focus will be fired on the correct object when it is in the foreground again.
			return
		# The new page has the same event params, so we must bypass NVDA's IAccessible caching.
		obj = getNVDAObjectFromEvent(self.windowHandle, winUser.OBJID_CLIENT, 0)
		if not obj:
			return
		eventHandler.queueEvent("gainFocus",obj)
 def delete(self):
     index = self.entriesList.GetFocusedItem()
     item = self.collection[index]
     self.collectionObject.delete(item)
     self.refreshList(index)
     if len(self.collection) == 0: return
     self.entriesList.SetFocus()
     time.sleep(0.1)
     api.processPendingEvents()
     obj = api.getFocusObject()
     queueEvent("gainFocus", obj)
示例#40
0
def clickButtonWithoutMoving(window):
    oldSpeechMode = getSpeechMode()
    setSpeechMode_off()
    currentObj = api.getFocusObject()
    name = clickButton(window)
    currentObj.setFocus()
    eventHandler.queueEvent("gainFocus", currentObj)
    time.sleep(0.1)
    api.processPendingEvents()
    setSpeechMode(oldSpeechMode)
    return name
示例#41
0
def reportSelectedCandidate(candidateObject,allowDuplicate=False,newList=False):
	if not eventHandler.isPendingEvents("gainFocus") and (allowDuplicate or candidateObject!=api.getFocusObject()):
		if not isinstance(api.getFocusObject(),BaseCandidateItem):
			oldCandidateItemsText=None
			candidateObject.container=api.getFocusObject()
			eventHandler.queueEvent("foreground",candidateObject)
		else:
			oldCandidateItemsText=api.getFocusObject().visibleCandidateItemsText
			candidateObject.container=api.getFocusObject().container
		if config.conf["inputComposition"]["autoReportAllCandidates"] and (newList or candidateObject.visibleCandidateItemsText!=oldCandidateItemsText):
			queueHandler.queueFunction(queueHandler.eventQueue,ui.message,candidateObject.visibleCandidateItemsText)
		eventHandler.queueEvent("gainFocus",candidateObject)
示例#42
0
def processShowWinEvent(window,objectID,childID):
	# eventHandler.shouldAcceptEvent only accepts show events for a few specific cases.
	# Narrow this further to only accept events for clients or custom objects.
	if objectID==winUser.OBJID_CLIENT or objectID>0:
		NVDAEvent=winEventToNVDAEvent(winUser.EVENT_OBJECT_SHOW,window,objectID,childID)
		if NVDAEvent:
			eventHandler.queueEvent(*NVDAEvent)
	#nvdajp begin
	if winUser.getClassName(window)[:5] in ('ATOK2', 'ATOK3'):
		NVDAEvent=winEventToNVDAEvent(winUser.EVENT_OBJECT_SHOW,window,objectID,childID)
		if NVDAEvent:
			eventHandler.queueEvent(*NVDAEvent)
示例#43
0
def clickButton(window):
    obj = findWindowNVDAObject(window)
    if obj is None:
        return None
    oldSpeechMode = getSpeechMode()
    setSpeechMode_off()
    obj.IAccessibleObject.accDoDefaultAction(0)
    eventHandler.queueEvent("gainFocus", obj)
    time.sleep(0.1)
    api.processPendingEvents()
    setSpeechMode(oldSpeechMode)
    return obj.name
    def event_UIA_window_windowOpen(self, obj, nextHandler):
        firstChild = obj.firstChild
        # Handle Ime Candidate UI being shown
        if isinstance(firstChild, ImeCandidateUI):
            eventHandler.queueEvent("show", firstChild)
            return

        # Make sure to announce most recently used emoji first in post-1709 builds.
        # Fake the announcement by locating 'most recently used" category and calling selected event on this.
        # However, in build 17666 and later, child count is the same for both emoji panel and hardware keyboard candidates list.
        # Thankfully first child automation ID's are different for each modern input technology.
        # However this event is raised when the input panel closes.
        if obj.firstChild is None:
            return
        # #9104: different aspects of modern input panel are represented by automation iD's.
        childAutomationID = obj.firstChild.UIAElement.cachedAutomationID
        # Emoji panel for 1709 (build 16299) and 1803 (17134).
        emojiPanelInitial = winVersion.WIN10_1709
        # This event is properly raised in build 17134.
        emojiPanelWindowOpenEvent = winVersion.WIN10_1803
        if (emojiPanelInitial <= winVersion.getWinVer() <=
                emojiPanelWindowOpenEvent and childAutomationID in
            ("TEMPLATE_PART_ExpressiveInputFullViewFuntionBarItemControl",
             "TEMPLATE_PART_ExpressiveInputFullViewFuntionBarCloseButton")):
            self.event_UIA_elementSelected(obj.lastChild.firstChild,
                                           nextHandler)
        # Handle hardware keyboard suggestions.
        # Treat it the same as CJK composition list - don't announce this if candidate announcement setting is off.
        elif childAutomationID == "CandidateWindowControl" and config.conf[
                "inputComposition"]["autoReportAllCandidates"]:
            try:
                self.event_UIA_elementSelected(
                    obj.firstChild.firstChild.firstChild, nextHandler)
            except AttributeError:
                # Because this is dictation window.
                pass
        # Emoji panel in build 17666 and later (unless this changes).
        elif childAutomationID == "TEMPLATE_PART_ExpressionGroupedFullView":
            self._emojiPanelJustOpened = True
            try:
                self.event_UIA_elementSelected(
                    obj.firstChild.children[-2].firstChild.firstChild,
                    nextHandler)
            except AttributeError:
                # In build 18272's emoji panel, emoji list becomes empty in some situations.
                pass
        # Clipboard history.
        # Move to clipboard list so element selected event can pick it up.
        # #9103: if clipboard is empty, a status message is displayed instead, and luckily it is located where clipboard data items can be found.
        elif childAutomationID == "TEMPLATE_PART_ClipboardTitleBar":
            self.event_UIA_elementSelected(obj.children[-2], nextHandler)
        nextHandler()
 def event_show(self):
     # The IME candidate UI is shown.
     # Report the current candidates page and the currently selected item.
     # Sometimes UIA does not fire an elementSelected event when it is first opened,
     # Therefore we must fake it here.
     if (self.UIAAutomationId == "IME_Prediction_Window"):
         candidateItem = self.firstChild
         eventHandler.queueEvent("UIA_elementSelected", candidateItem)
     elif (self.firstChild
           and self.firstChild.role == controlTypes.Role.LIST
           and isinstance(self.firstChild.firstChild, ImeCandidateItem)):
         candidateItem = self.firstChild.firstChild
         eventHandler.queueEvent("UIA_elementSelected", candidateItem)
示例#46
0
文件: itunes.py 项目: lpintes/NVDA
	def event_stateChange(self):
		# iTunes has indicated that a page has died and been replaced by a new one.
		focus = api.getFocusObject()
		if not winUser.isDescendantWindow(self.windowHandle, focus.windowHandle):
			return
		# The new page has the same event params, so we must bypass NVDA's IAccessible caching.
		obj = NVDAObjects.IAccessible.getNVDAObjectFromEvent(focus.windowHandle, winUser.OBJID_CLIENT, 0)
		if not obj:
			return
		if focus.treeInterceptor:
			speech.cancelSpeech()
			treeInterceptorHandler.killTreeInterceptor(focus.treeInterceptor)
		eventHandler.queueEvent("gainFocus",obj)
示例#47
0
	def event_stateChange(self):
		# iTunes has indicated that a page has died and been replaced by a new one.
		focus = api.getFocusObject()
		if not winUser.isDescendantWindow(self.windowHandle, focus.windowHandle):
			return
		if focus.role:
			# The old document is still alive.
			return
		# The new page has the same event params, so we must bypass NVDA's IAccessible caching.
		obj = NVDAObjects.IAccessible.getNVDAObjectFromEvent(focus.windowHandle, winUser.OBJID_CLIENT, 0)
		if not obj:
			return
		eventHandler.queueEvent("gainFocus",obj)
示例#48
0
def event_caret(vmID, accContext, hwnd):
    jabContext = JABContext(hwnd=hwnd, vmID=vmID, accContext=accContext)
    if jabContext.hwnd:
        focus = api.getFocusObject()
        obj = focus if (
            isinstance(focus, NVDAObjects.JAB.JAB)
            and focus.jabContext == jabContext) else NVDAObjects.JAB.JAB(
                jabContext=jabContext)
        if obj:
            eventHandler.queueEvent("caret", obj)
    else:
        log.debugWarning(
            "Unable to obtain window handle for accessible context")
示例#49
0
 def IUIAutomationNotificationEventHandler_HandleNotificationEvent(
         self, sender, NotificationKind, NotificationProcessing,
         displayString, activityId):
     if not self.MTAThreadInitEvent.isSet():
         # UIAHandler hasn't finished initialising yet, so just ignore this event.
         return
     import NVDAObjects.UIA
     obj = NVDAObjects.UIA.UIA(UIAElement=sender)
     eventHandler.queueEvent("UIA_notification",
                             obj,
                             notificationKind=NotificationKind,
                             notificationProcessing=NotificationProcessing,
                             displayString=displayString,
                             activityId=activityId)
示例#50
0
		def IUIAutomationEventHandler_HandleAutomationEvent(self,sender,eventID):
			if not handler:
				# UIAHandler hasn't finished initialising yet, so just ignore this event.
				return
			NVDAEventName=UIAEventIdsToNVDAEventNames.get(eventID,None)
			if not NVDAEventName:
				return
			if not self.UIAHandlerRef().isNativeUIAElement(sender):
				return
			import NVDAObjects.UIA
			obj=NVDAObjects.UIA.UIA(UIAElement=sender)
			if not obj:
				return
			eventHandler.queueEvent(NVDAEventName,obj)
示例#51
0
	def IUIAutomationPropertyChangedEventHandler_HandlePropertyChangedEvent(self,sender,propertyId,newValue):
		if not self.MTAThreadInitEvent.isSet:
			# UIAHandler hasn't finished initialising yet, so just ignore this event.
			return
		NVDAEventName=UIAPropertyIdsToNVDAEventNames.get(propertyId,None)
		if not NVDAEventName:
			return
		if not self.isNativeUIAElement(sender):
			return
		import NVDAObjects.UIA
		obj=NVDAObjects.UIA.UIA(UIAElement=sender)
		if not obj:
			return
		eventHandler.queueEvent(NVDAEventName,obj)
示例#52
0
	def __init__(self, parent, focus, rangeType):
		self.rangeType = rangeType
		self.dialogClass = GrammaticalErrorsDialog
		self.noElement = _("No gramatical error")
		wordApp = focus._WinwordWindowObject.Application
		if not wordApp.Options.CheckGrammarAsYouType:
			self.collection = None
			ui.message(_("Not available, Check grammar as you type is not activated"))
			time.sleep(3.0)
			api.processPendingEvents()
			time.sleep(0.2)
			queueEvent("gainFocus", api.getFocusObject())
			return
		super(GrammaticalErrors, self).__init__(parent, focus)
示例#53
0
def event_valueChange(vmID, event, source, oldVal, newVal):
    jabContext = JABContext(vmID=vmID, accContext=source)
    if jabContext.hwnd:
        focus = api.getFocusObject()
        obj = focus if (
            isinstance(focus, NVDAObjects.JAB.JAB)
            and focus.jabContext == jabContext) else NVDAObjects.JAB.JAB(
                jabContext=jabContext)
        if obj:
            eventHandler.queueEvent("valueChange", obj)
    else:
        log.debugWarning(
            "Unable to obtain window handle for accessible context")
    bridgeDll.releaseJavaObject(vmID, event)
示例#54
0
文件: core.py 项目: nishimotz/nvda
def _setInitialFocus():
	"""Sets the initial focus if no focus event was received at startup.
	"""
	import eventHandler
	import api
	if eventHandler.lastQueuedFocusObject:
		# The focus has already been set or a focus event is pending.
		return
	try:
		focus = api.getDesktopObject().objectWithFocus()
		if focus:
			eventHandler.queueEvent('gainFocus', focus)
	except:
		log.exception("Error retrieving initial focus")
示例#55
0
文件: core.py 项目: joeldodson/nvda
def _setInitialFocus():
    """Sets the initial focus if no focus event was received at startup.
	"""
    import eventHandler
    import api
    if eventHandler.lastQueuedFocusObject:
        # The focus has already been set or a focus event is pending.
        return
    try:
        focus = api.getDesktopObject().objectWithFocus()
        if focus:
            eventHandler.queueEvent('gainFocus', focus)
    except:
        log.exception("Error retrieving initial focus")
示例#56
0
	def handleSelectionChange(self):
		"""Pushes focus to the newly selected object."""
		if getattr(self,"_isHandlingSelectionChange",False):
			# #3394: A COM event can cause this function to run within itself.
			# This can cause double speaking, so stop here if we're already running.
			return
		self._isHandlingSelectionChange=True
		try:
			obj=self.selection
			if not obj:
				obj=IAccessible(windowHandle=self.windowHandle,IAccessibleObject=self.IAccessibleObject,IAccessibleChildID=self.IAccessibleChildID)
			if obj and obj!=eventHandler.lastQueuedFocusObject:
				eventHandler.queueEvent("gainFocus",obj)
		finally:
			self._isHandlingSelectionChange=False
	def event_stateChange(self):
		# iTunes has indicated that a page has died and been replaced by a new one.
		# #5191: This is actually fired on the "iTunesWebViewControl" parent,
		# but AccessibleObjectFromEvent on this window returns the WebKit document as of iTunes 12.
		focus = api.getFocusObject()
		if self.windowHandle != focus.windowHandle:
			return
		# The new page has the same event params, so we must bypass NVDA's IAccessible caching.
		obj = NVDAObjects.IAccessible.getNVDAObjectFromEvent(focus.windowHandle, winUser.OBJID_CLIENT, 0)
		if not obj:
			return
		if focus.treeInterceptor:
			speech.cancelSpeech()
			treeInterceptorHandler.killTreeInterceptor(focus.treeInterceptor)
		eventHandler.queueEvent("gainFocus",obj)
示例#58
0
	def handleSelectionChange(self):
		"""Pushes focus to the newly selected object."""
		if getattr(self,"_isHandlingSelectionChange",False):
			# #3394: A COM event can cause this function to run within itself.
			# This can cause double speaking, so stop here if we're already running.
			return
		self._isHandlingSelectionChange=True
		try:
			obj=self.selection
			if not obj:
				obj=IAccessible(windowHandle=self.windowHandle,IAccessibleObject=self.IAccessibleObject,IAccessibleChildID=self.IAccessibleChildID)
			if obj and obj!=eventHandler.lastQueuedFocusObject:
				eventHandler.queueEvent("gainFocus",obj)
		finally:
			self._isHandlingSelectionChange=False