示例#1
0
def setNavigatorObject(obj,isFocus=False):
	"""Sets an object to be the current navigator object. Navigator objects can be used to navigate around the operating system (with the number pad) with out moving the focus. It also sets the current review position to None so that next time the review position is asked for, it is created from the navigator object.  
@param obj: the object that will be set as the current navigator object
@type obj: NVDAObjects.NVDAObject  
@param isFocus: true if the navigator object was set due to a focus change.
@type isFocus: bool
"""
	if not isinstance(obj,NVDAObjects.NVDAObject):
		return False
	globalVars.navigatorObject=obj
	oldPos=globalVars.reviewPosition
	oldPosObj=globalVars.reviewPositionObj
	globalVars.reviewPosition=None
	globalVars.reviewPositionObj=None
	reviewMode=review.getCurrentMode()
	# #3320: If in document review yet there is no document to review the mode should be forced to object. 
	if reviewMode=='document' and (not isinstance(obj.treeInterceptor,treeInterceptorHandler.DocumentTreeInterceptor)  or not obj.treeInterceptor.isReady or obj.treeInterceptor.passThrough):
		review.setCurrentMode('object',False)
	elif isinstance(obj.treeInterceptor,treeInterceptorHandler.DocumentTreeInterceptor) and obj.treeInterceptor.isReady and not obj.treeInterceptor.passThrough:
		if reviewMode=='object':
			review.setCurrentMode('document',False)
		if isFocus:
			globalVars.reviewPosition=obj.treeInterceptor.makeTextInfo(textInfos.POSITION_CARET)
			globalVars.reviewPositionObj=globalVars.reviewPosition
	eventHandler.executeEvent("becomeNavigatorObject",obj)
示例#2
0
def executeMouseMoveEvent(x,y):
	global currentMouseWindow
	desktopObject=api.getDesktopObject()
	displays = [ wx.Display(i).GetGeometry() for i in xrange(wx.Display.GetCount()) ]
	x, y = getMouseRestrictedToScreens(x, y, displays)
	screenWidth, screenHeight, minPos = getTotalWidthAndHeightAndMinimumPosition(displays)

	if config.conf["mouse"]["audioCoordinatesOnMouseMove"]:
		playAudioCoordinates(x, y, screenWidth, screenHeight, minPos,
			config.conf['mouse']['audioCoordinates_detectBrightness'],
			config.conf['mouse']['audioCoordinates_blurFactor'])

	oldMouseObject=api.getMouseObject()
	mouseObject=desktopObject.objectFromPoint(x, y)
	while mouseObject and mouseObject.beTransparentToMouse:
		mouseObject=mouseObject.parent
	if not mouseObject:
		return
	if oldMouseObject==mouseObject:
		mouseObject=oldMouseObject
	else:
		api.setMouseObject(mouseObject)
	try:
		eventHandler.executeEvent("mouseMove",mouseObject,x=x,y=y)
		oldMouseObject=mouseObject
	except:
		log.error("api.notifyMouseMoved", exc_info=True)
示例#3
0
文件: NVDAHelper.py 项目: bramd/nvda
def handleInputCandidateListUpdate(candidatesString,selectionIndex,inputMethod):
	candidateStrings=candidatesString.split('\n')
	import speech
	from NVDAObjects.inputComposition import InputComposition, CandidateList, CandidateItem
	focus=api.getFocusObject()
	if not (0<=selectionIndex<len(candidateStrings)):
		if isinstance(focus,CandidateItem):
			oldSpeechMode=speech.speechMode
			speech.speechMode=speech.speechMode_off
			eventHandler.executeEvent("gainFocus",focus.parent)
			speech.speechMode=oldSpeechMode
		return
	oldCandidateItemsText=None
	if isinstance(focus,CandidateItem):
		oldCandidateItemsText=focus.visibleCandidateItemsText
		parent=focus.parent
		wasCandidate=True
	else:
		parent=focus
		wasCandidate=False
	item=CandidateItem(parent=parent,candidateStrings=candidateStrings,candidateIndex=selectionIndex,inputMethod=inputMethod)
	if wasCandidate and focus.windowHandle==item.windowHandle and focus.candidateIndex==item.candidateIndex and focus.name==item.name:
		return
	if config.conf["inputComposition"]["autoReportAllCandidates"] and item.visibleCandidateItemsText!=oldCandidateItemsText:
		import ui
		ui.message(item.visibleCandidateItemsText)
	eventHandler.executeEvent("gainFocus",item)
示例#4
0
	def event_gainFocus(self):
		selection=self.excelWindowObject.Selection
		if selection.Count>1:
			obj=ExcelSelection(windowHandle=self.windowHandle,excelWindowObject=self.excelWindowObject,excelRangeObject=selection)
		else:
			obj=ExcelCell(windowHandle=self.windowHandle,excelWindowObject=self.excelWindowObject,excelCellObject=selection)
		eventHandler.executeEvent("gainFocus",obj)
示例#5
0
文件: api.py 项目: lpintes/NVDA
def setNavigatorObject(obj,isFocus=False):
	"""Sets an object to be the current navigator object. Navigator objects can be used to navigate around the operating system (with the number pad) with out moving the focus. It also sets the current review position to None so that next time the review position is asked for, it is created from the navigator object.  
@param obj: the object that will be set as the current navigator object
@type obj: NVDAObjects.NVDAObject  
@param isFocus: true if the navigator object was set due to a focus change.
@type isFocus: bool
"""
	if not isinstance(obj,NVDAObjects.NVDAObject):
		return False
	globalVars.navigatorObject=obj
	oldPos=globalVars.reviewPosition
	oldPosObj=globalVars.reviewPositionObj
	globalVars.reviewPosition=None
	globalVars.reviewPositionObj=None
	reviewMode=review.getCurrentMode()
	# #3320: If in document review yet there is no document to review the mode should be forced to object. 
	if reviewMode=='document' and (not obj.treeInterceptor or not obj.treeInterceptor.isReady or obj.treeInterceptor.passThrough):
		review.setCurrentMode('object',False)
	elif isFocus and reviewMode=='object' and obj.treeInterceptor and obj.treeInterceptor.isReady and not obj.treeInterceptor.passThrough:
		review.setCurrentMode('document',False)
	#Specifically handle when the navigator object is set due to a focus change in a virtualBuffer
	#The focus change may have been becaus the caret was moved, which caused the focus change.
	#If so, don't clober the review position as it will have been already set to a more accurate position.
	if isFocus and oldPos and oldPos.obj is obj.treeInterceptor and isinstance(obj.treeInterceptor,virtualBuffers.VirtualBuffer):
		try:
			objPos=obj.treeInterceptor.makeTextInfo(obj)
		except LookupError:
			objPos=None
		if objPos and objPos.isOverlapping(oldPos):
			globalVars.reviewPosition=oldPos
			globalVars.reviewPositionObj=oldPosObj
	eventHandler.executeEvent("becomeNavigatorObject",obj)
示例#6
0
	def event_gainFocus(self):
		if mouseHandler.lastMouseEventTime < time.time() - 0.2:
			# This focus change was not caused by a mouse event.
			# If the mouse is on another toolbar control, the notification area toolbar will rudely
			# bounce the focus back to the object under the mouse after a brief pause.
			# Moving the mouse to the focus object isn't a good solution because
			# sometimes, the focus can't be moved away from the object under the mouse.
			# Therefore, move the mouse out of the way.
			winUser.setCursorPos(0, 0)

		if self.role == controlTypes.ROLE_TOOLBAR:
			# Sometimes, the toolbar itself receives the focus instead of the focused child.
			# However, the focused child still has the focused state.
			for child in self.children:
				if child.hasFocus:
					# Redirect the focus to the focused child.
					eventHandler.executeEvent("gainFocus", child)
					return
			# We've really landed on the toolbar itself.
			# This was probably caused by moving the mouse out of the way in a previous focus event.
			# This previous focus event is no longer useful, so cancel speech.
			speech.cancelSpeech()

		if eventHandler.isPendingEvents("gainFocus"):
			return
		super(NotificationArea, self).event_gainFocus()
示例#7
0
文件: NVDAHelper.py 项目: bramd/nvda
def handleInputCompositionStart(compositionString,selectionStart,selectionEnd,isReading):
	import speech
	from NVDAObjects.inputComposition import InputComposition
	from NVDAObjects.behaviors import CandidateItem
	focus=api.getFocusObject()
	if focus.parent and isinstance(focus.parent,InputComposition):
		#Candidates infront of existing composition string
		announce=not config.conf["inputComposition"]["announceSelectedCandidate"]
		focus.parent.compositionUpdate(compositionString,selectionStart,selectionEnd,isReading,announce=announce)
		return 0
	#IME keeps updating input composition while the candidate list is open
	#Therefore ignore new composition updates if candidate selections are configured for speaking.
	if config.conf["inputComposition"]["announceSelectedCandidate"] and isinstance(focus,CandidateItem):
		return 0
	if not isinstance(focus,InputComposition):
		parent=api.getDesktopObject().objectWithFocus()
		# #5640: Although we want to use the most correct focus (I.e. OS, not NVDA), if they are the same, we definitely want to use the original instance, so that state such as auto selection is maintained.
		if parent==focus:
			parent=focus
		curInputComposition=InputComposition(parent=parent)
		oldSpeechMode=speech.speechMode
		speech.speechMode=speech.speechMode_off
		eventHandler.executeEvent("gainFocus",curInputComposition)
		focus=curInputComposition
		speech.speechMode=oldSpeechMode
	focus.compositionUpdate(compositionString,selectionStart,selectionEnd,isReading)
示例#8
0
 def setFocus(self):
     ti = self.parent.treeInterceptor
     if isinstance(ti, virtualBuffers.VirtualBuffer):
         # 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 math, as math isn't focusable.
         ti._enteringFromOutside = True
     eventHandler.executeEvent("gainFocus", self)
示例#9
0
	def script_changeSelection(self,gesture):
		gesture.send()
		selection=self.excelWindowObject.Selection
		if selection.Count>1:
			obj=ExcelSelection(windowHandle=self.windowHandle,excelWindowObject=self.excelWindowObject,excelRangeObject=selection)
		else:
			obj=ExcelCell(windowHandle=self.windowHandle,excelWindowObject=self.excelWindowObject,excelCellObject=selection)
		eventHandler.executeEvent("gainFocus",obj)
示例#10
0
文件: excel.py 项目: lpintes/NVDA
	def event_gainFocus(self):
		selection=self._getSelection()
		dropdown=self._getDropdown()
		if dropdown:
			if selection:
				dropdown.parent=selection
			eventHandler.executeEvent('gainFocus',dropdown)
			return
		if selection:
			eventHandler.executeEvent('gainFocus',selection)
	def event_show(self, obj, nextHandler):
		if obj.role == controlTypes.ROLE_PANE:
			self.isAutocomplete=True
			core.callLater(100, self.waitforAndReportDestruction,obj)
			#get the edit field if the weak reference still has it.
			edit = self._edit()
			if not edit:
				return
			eventHandler.executeEvent("suggestionsOpened", edit)
		nextHandler()
	def _reportFocusEnteredEventForParent(self, obj):
		"""checks if we need to fire a focusEntered event for the selected entry's parent, and fires an event if we need to"""
		if obj.parent.name == "Active Files" and self.shouldFireFocusEnteredEventFiles:
			eventHandler.executeEvent("focusEntered", obj.parent)
			self.shouldFireFocusEnteredEventFiles = False
			self.shouldFireFocusEnteredEventTools = True
		if obj.parent.name == "Active Tool Windows" and self.shouldFireFocusEnteredEventTools:
			eventHandler.executeEvent("focusEntered", obj.parent)
			self.shouldFireFocusEnteredEventFiles = True
			self.shouldFireFocusEnteredEventTools = False
示例#13
0
 def _movementHelper(self, dir):
     if ((dir and self.columnNumber == 1)
             or (not dir and self.columnNumber == 0)):
         ui.message(translate("Edge of table"))
         return
     if dir == 0:
         self.columnNumber -= 1
     elif dir == 1:
         self.columnNumber += 1
     self._addHeaderNextTime = True
     eventHandler.executeEvent("valueChange", self)
示例#14
0
 def event_gainFocus(self):
     try:
         msg = self.nativeOm.ActiveExplorer().selection[0]
     except:
         msg = None
         pass
     if msg:
         self.curMessageItem = MessageItem(self, msg)
     super(MessageList_pre2003, self).event_gainFocus()
     if msg:
         eventHandler.executeEvent("gainFocus", self.curMessageItem)
示例#15
0
	def event_gainFocus(self):
		try:
			msg=self.nativeOm.ActiveExplorer().selection[0]
		except:
			msg=None
			pass
		if msg:
			self.curMessageItem=MessageItem(self,msg)
		super(MessageList_pre2003,self).event_gainFocus()
		if msg:
			eventHandler.executeEvent("gainFocus",self.curMessageItem)
示例#16
0
 def fireFocusOnSelection(self):
     selection = self.excelWindowObject.Selection
     if selection.Count > 1:
         obj = ExcelSelection(windowHandle=self.windowHandle,
                              excelWindowObject=self.excelWindowObject,
                              excelRangeObject=selection)
     else:
         obj = ExcelCell(windowHandle=self.windowHandle,
                         excelWindowObject=self.excelWindowObject,
                         excelCellObject=selection)
     eventHandler.executeEvent("gainFocus", obj)
示例#17
0
    def event_UIA_elementSelected(self):
        if self.editor and not self.appModule.openedIntellisensePopup:
            eventHandler.executeEvent("suggestionsOpened",
                                      api.getFocusObject())

        if self.appModule.selectedIntellisenseItem != self:
            # Prepare to read the item when it's name changes:
            self.appModule.readIntellisenseItem = True
            speech.cancelSpeech()
            ui.message(self.name)
            self.appModule.selectedIntellisenseItem = self
	def waitforAndReportDestruction(self, obj):
		if obj.parent: #None when no parent.
			core.callLater(100, self.waitforAndReportDestruction,obj)
			return
		#The object is dead.
		self.isAutocomplete=False
		#get the edit field if the weak reference still has it.
		edit = self._edit()
		if not edit:
			return
		eventHandler.executeEvent("suggestionsClosed", edit)
示例#19
0
	def _caretMovementScriptHelper(self, gesture, unit):
		try:
			info=self.makeTextInfo(textInfos.POSITION_CARET)
		except:
			gesture.send()
			return
		bookmark=info.bookmark
		gesture.send()
		if not self._hasCaretMoved(bookmark) and self.shouldFireCaretMovementFailedEvents:
			eventHandler.executeEvent("caretMovementFailed", self, gesture=gesture)
		self._caretScriptPostMovedHelper(unit)
示例#20
0
 def waitforAndReportDestruction(self, obj):
     if obj.parent:  #None when no parent.
         core.callLater(100, self.waitforAndReportDestruction, obj)
         return
     #The object is dead.
     self.isAutocomplete = False
     #get the edit field if the weak reference still has it.
     edit = self._edit()
     if not edit:
         return
     eventHandler.executeEvent("suggestionsClosed", edit)
示例#21
0
def setNavigatorObject(obj):
    """Sets an object to be the current navigator object. Navigator objects can be used to navigate around the operating system (with the number pad) with out moving the focus. It also sets the current review position to None so that next time the review position is asked for, it is created from the navigator object.  
@param obj: the object that will be set as the current navigator object
@type obj: NVDAObjects.NVDAObject  
"""
    if not isinstance(obj, NVDAObjects.NVDAObject):
        return False
    globalVars.navigatorObject = obj
    globalVars.reviewPosition = None
    globalVars.reviewPositionObj = None
    eventHandler.executeEvent("becomeNavigatorObject", obj)
示例#22
0
def setNavigatorObject(obj):
	"""Sets an object to be the current navigator object. Navigator objects can be used to navigate around the operating system (with the number pad) with out moving the focus. It also sets the current review position to None so that next time the review position is asked for, it is created from the navigator object.  
@param obj: the object that will be set as the current navigator object
@type obj: NVDAObjects.NVDAObject  
"""
	if not isinstance(obj,NVDAObjects.NVDAObject):
		return False
	globalVars.navigatorObject=obj
	globalVars.reviewPosition=None
	globalVars.reviewPositionObj=None
	eventHandler.executeEvent("becomeNavigatorObject",obj)
示例#23
0
	def _caretMovementScriptHelper(self, gesture, unit):
		try:
			info=self.makeTextInfo(textInfos.POSITION_CARET)
		except:
			gesture.send()
			return
		bookmark=info.bookmark
		gesture.send()
		caretMoved,newInfo=self._hasCaretMoved(bookmark) 
		if not caretMoved and self.shouldFireCaretMovementFailedEvents:
			eventHandler.executeEvent("caretMovementFailed", self, gesture=gesture)
		self._caretScriptPostMovedHelper(unit,gesture,newInfo)
示例#24
0
	def event_gainFocus(self):
		if eventHandler.isPendingEvents("gainFocus"):
			return

		child = self.activeChild
		if child:
			# QT doesn't fire focus on the active child as it should, so redirect the focus.
			self.event_focusEntered()
			eventHandler.executeEvent("gainFocus", child)
			return

		return super(Container, self).event_gainFocus()
示例#25
0
def processDesktopSwitchWinEvent(window,objectID,childID):
	hDesk=windll.user32.OpenInputDesktop(0, False, 0)
	if hDesk!=0:
		windll.user32.CloseDesktop(hDesk)
		core.callLater(200, _correctFocus)
	else:
		# Switching to a secure desktop.
		# We don't receive key up events for any keys down before switching to a secure desktop,
		# so clear our recorded modifiers.
		keyboardHandler.currentModifiers.clear()
		obj=SecureDesktopNVDAObject(windowHandle=window)
		eventHandler.executeEvent("gainFocus",obj)
	def _movementHelper(self, dir):
		if (
			(dir and self.columnNumber == 1) or
			(not dir and self.columnNumber==0)):
			ui.message(translate("Edge of table"))
			return
		if dir == 0:
			self.columnNumber-=1
		elif dir == 1:
			self.columnNumber+=1
		self._addHeaderNextTime = True
		eventHandler.executeEvent("valueChange", self)
示例#27
0
def processDesktopSwitchWinEvent(window, objectID, childID):
    hDesk = windll.user32.OpenInputDesktop(0, False, 0)
    if hDesk != 0:
        windll.user32.CloseDesktop(hDesk)
        core.callLater(200, _correctFocus)
    else:
        # Switching to a secure desktop.
        # We don't receive key up events for any keys down before switching to a secure desktop,
        # so clear our recorded modifiers.
        keyboardHandler.currentModifiers.clear()
        obj = SecureDesktopNVDAObject(windowHandle=window)
        eventHandler.executeEvent("gainFocus", obj)
def processDesktopSwitchWinEvent(window,objectID,childID):
	hDesk=ctypes.windll.user32.OpenInputDesktop(0, False, 0)
	#name = ctypes.create_string_buffer(256)
	#res=ctypes.windll.user32.GetUserObjectInformationA(desktop, 2, ctypes.byref(name), ctypes.sizeof(name), None)
	#speech.speakMessage(name.value)
	if hDesk!=0:
		ctypes.windll.user32.CloseDesktop(hDesk)
		import wx
		wx.CallLater(200, _correctFocus)
	else:
		obj=SecureDesktopNVDAObject(windowHandle=window)
		eventHandler.executeEvent("gainFocus",obj)
示例#29
0
    def event_gainFocus(self):
        if eventHandler.isPendingEvents("gainFocus"):
            return

        child = self.activeChild
        if child:
            # QT doesn't fire focus on the active child as it should, so redirect the focus.
            self.event_focusEntered()
            eventHandler.executeEvent("gainFocus", child)
            return

        return super(Container, self).event_gainFocus()
示例#30
0
	def event_gainFocus(self):
		if eventHandler.isPendingEvents("gainFocus"):
			return

		widget = self._containedWidget
		if widget:
			# This is a widget container.
			# Redirect the focus to the contained widget, since QT doesn't do it properly.
			self.event_focusEntered()
			eventHandler.executeEvent("gainFocus", widget)
			return

		return super(Client, self).event_gainFocus()
示例#31
0
    def event_gainFocus(self):
        if eventHandler.isPendingEvents("gainFocus"):
            return

        widget = self._containedWidget
        if widget:
            # This is a widget container.
            # Redirect the focus to the contained widget, since QT doesn't do it properly.
            self.event_focusEntered()
            eventHandler.executeEvent("gainFocus", widget)
            return

        return super(Client, self).event_gainFocus()
示例#32
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)
示例#33
0
 def setFocus(self):
     eventHandler.executeEvent("gainFocus", self)
     ui.message(self.data.pointer['name'])
     if "shortcut" in self.data.pointer and self.data.pointer[
             "shortcut"] != "-1":
         ui.message(
             _("f{shortcut}").format(
                 shortcut=self.data.pointer["shortcut"]))
     if self.data.pointer["type"] == "menu":
         ui.message(_("subMenu"))
     ui.message(
         _("{number} of {total}").format(
             number=self.data.path[-1] + 1,
             total=self.data.count,
         ))
示例#34
0
文件: outlook.py 项目: ruifontes/nvda
	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 script_accessLanguageBar(self, gesture):
     obj = api.getDesktopObject()
     simpleReviewMode = config.conf["reviewCursor"]["simpleReviewMode"]
     refObject = obj.simpleFirstChild if simpleReviewMode else obj.firstChild
     while refObject:
         refObject = refObject.simpleNext if simpleReviewMode else refObject.next
         if refObject.name == "Language bar":
             break
     countOne = refObject.childCount
     for i in range(0, countOne):
         if refObject.getChild(i).name == "Settings":
             break
     if refObject:
         refObject.getChild(i).doAction()
         eventHandler.executeEvent('gainFocus', refObject.getChild(i).next)
示例#36
0
 def event_UIA_window_windowOpen(self, obj, nextHandler):
     # Send UIA window open event to input app window.
     if isinstance(
             obj, UIA
     ) and obj.UIAElement.cachedClassName == "ApplicationFrameWindow":
         inputPanelWindow = obj.firstChild
         inputPanelAppName = (
             # 19H2 and earlier
             "windowsinternal_composableshell_experiences_textinput_inputapp",
             # 20H1 and later
             "textinputhost")
         if inputPanelWindow and inputPanelWindow.appModule.appName in inputPanelAppName:
             eventHandler.executeEvent("UIA_window_windowOpen",
                                       inputPanelWindow)
             return
     nextHandler()
示例#37
0
 def script_moveByMessage(self, gesture):
     if hasattr(self, 'curMessageItem'):
         oldEntryID = self.curMessageItem.msg.entryID
     else:
         oldEntryID = None
     gesture.send()
     try:
         msg = self.nativeOm.ActiveExplorer().selection[0]
     except:
         msg = None
         pass
     if msg:
         messageItem = MessageItem(self, msg)
         newEntryID = messageItem.msg.entryID
         if newEntryID != oldEntryID:
             self.curMessageItem = messageItem
             eventHandler.executeEvent("gainFocus", messageItem)
示例#38
0
	def script_moveByMessage(self,gesture):
		if hasattr(self,'curMessageItem'):
			oldEntryID=self.curMessageItem.msg.entryID
		else:
			oldEntryID=None
		gesture.send()
		try:
			msg=self.nativeOm.ActiveExplorer().selection[0]
		except:
			msg=None
			pass
		if msg:
			messageItem=MessageItem(self,msg)
			newEntryID=messageItem.msg.entryID
			if newEntryID!=oldEntryID:
				self.curMessageItem=messageItem
				eventHandler.executeEvent("gainFocus",messageItem)
	def script_changeSelection(self,gesture):
		oldSelection=self._getSelection()
		gesture.send()
		newSelection=None
		curTime=startTime=time.time()
		while (curTime-startTime)<=0.15:
			if scriptHandler.isScriptWaiting():
				# Prevent lag if keys are pressed rapidly
				return
			if eventHandler.isPendingEvents('gainFocus'):
				return
			newSelection=self._getSelection()
			if newSelection and newSelection!=oldSelection:
				break
			api.processPendingEvents(processEventQueue=False)
			time.sleep(0.015)
			curTime=time.time()
		if newSelection:
			eventHandler.executeEvent('gainFocus',newSelection)
示例#40
0
	def script_changeSelection(self,gesture):
		oldSelection=self._getSelection()
		gesture.send()
		newSelection=None
		curTime=startTime=time.time()
		while (curTime-startTime)<=0.15:
			if scriptHandler.isScriptWaiting():
				# Prevent lag if keys are pressed rapidly
				return
			if eventHandler.isPendingEvents('gainFocus'):
				return
			newSelection=self._getSelection()
			if newSelection and newSelection!=oldSelection:
				break
			api.processPendingEvents(processEventQueue=False)
			time.sleep(0.015)
			curTime=time.time()
		if newSelection:
			eventHandler.executeEvent('gainFocus',newSelection)
示例#41
0
	def event_gainFocus(self, obj, nextHandler):
		if not eventHandler.isPendingEvents("gainFocus") and obj.windowClassName == "Chrome_WidgetWin_0" and obj.role == controlTypes.ROLE_WINDOW:
			# Spotify doesn't fire focus on the correct object when it gets the foreground.
			try:
				focus = obj.activeChild.activeChild
			except AttributeError:
				focus = None
			if focus:
				return eventHandler.executeEvent("gainFocus", focus)
		return nextHandler()
示例#42
0
    def script_reset_shortcut(self, gesture):
        if self.data.pointer['type'] == 'menu':
            ui.message(_("sub menu no shortcut"))
            return

        id_ = self.data.pointer['id']
        slot = self.data.pointer['shortcut']
        if slot == "-1":
            ui.message(_("no set shortcut"))
            return

        for item in latexAll:
            if item["id"] == id_:
                item["shortcut"] = "-1"
                break

        self.update_menu()
        ui.message(_("clear shortcut {slot}").format(slot=slot))
        eventHandler.executeEvent("gainFocus", self.parent)
 def event_UIA_window_windowOpen(self, obj, nextHandler):
     # 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.
     inputPanel = obj.firstChild
     if inputPanel is None:
         return
     inputPanelAutomationID = inputPanel.UIAElement.cachedAutomationID
     # Emoji panel for build 16299 and 17134.
     # This event is properly raised in build 17134.
     if not winVersion.isWin10(
             version=1809
     ) and inputPanelAutomationID in self._classicEmojiPanelAutomationID:
         eventHandler.executeEvent("UIA_elementSelected",
                                   obj.lastChild.firstChild)
     # Handle hardware keyboard and CJK IME suggestions.
     # Treat it the same as CJK composition list - don't announce this if candidate announcement setting is off.
     # In fact, in 20H1, this is the CJK IME candidates window.
     elif inputPanelAutomationID in (
             "CandidateWindowControl", "IME_Candidate_Window",
             "IME_Prediction_Window"
     ) and config.conf["inputComposition"]["autoReportAllCandidates"]:
         try:
             eventHandler.executeEvent("UIA_elementSelected",
                                       inputPanel.firstChild.firstChild)
         except AttributeError:
             # Because this is dictation window.
             pass
     # Emoji panel in build 17666 and later (unless this changes).
     elif inputPanelAutomationID == "TEMPLATE_PART_ExpressionGroupedFullView":
         self._emojiPanelJustOpened = True
         # On some systems, there is something else besides grouping controls, so another child control must be used.
         emojisList = inputPanel.children[-2]
         if emojisList.UIAElement.cachedAutomationID != "TEMPLATE_PART_Items_GridView":
             emojisList = emojisList.previous
         try:
             eventHandler.executeEvent("UIA_elementSelected",
                                       emojisList.firstChild.firstChild)
         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.
     elif inputPanelAutomationID == "TEMPLATE_PART_ClipboardTitleBar":
         # Under some cases, clipboard tip text isn't shown on screen, causing clipboard history title to be announced instead of most recently copied item.
         clipboardHistory = obj.children[-2]
         if clipboardHistory.UIAElement.cachedAutomationID == inputPanelAutomationID:
             clipboardHistory = clipboardHistory.next
         eventHandler.executeEvent("UIA_elementSelected", clipboardHistory)
     nextHandler()
示例#44
0
    def script_set_shortcut(self, gesture):
        if self.data.pointer['type'] == 'menu':
            ui.message(_("menu can not set shortcut"))
            return

        id_ = self.data.pointer['id']
        slot = gesture.mainKeyName[1:]

        for item in latexAll:
            if item["id"] == id_:
                item["shortcut"] = slot
                break

        for item in latexAll:
            if item["id"] != id_ and item["shortcut"] == str(slot):
                item["shortcut"] = "-1"

        self.update_menu()
        ui.message(_("set shortcut {slot}").format(slot=slot))
        eventHandler.executeEvent("gainFocus", self.parent)
示例#45
0
	def navigationHelper(self,direction):
		excelWindowObject=self.rootNVDAObject.excelWindowObject
		cellPosition = excelWindowObject.activeCell
		try:
			if   direction == "left":
				cellPosition = cellPosition.Offset(0,-1)
			elif direction == "right":
				cellPosition = cellPosition.Offset(0,1)
			elif direction == "up":
				cellPosition = cellPosition.Offset(-1,0)
			elif direction == "down":
				cellPosition = cellPosition.Offset(1,0)
			#Start-of-Column
			elif direction == "startcol":
				cellPosition = cellPosition.end(xlUp)
			#Start-of-Row
			elif direction == "startrow":
				cellPosition = cellPosition.end(xlToLeft)
			#End-of-Row
			elif direction == "endrow":
				cellPosition = cellPosition.end(xlToRight)
			#End-of-Column
			elif direction == "endcol":
				cellPosition = cellPosition.end(xlDown)
			else:
				return
		except COMError:
			pass

		try:
			isMerged=cellPosition.mergeCells
		except (COMError,NameError):
			isMerged=False
		if isMerged:
			cellPosition=cellPosition.MergeArea(1)
			obj=ExcelMergedCell(windowHandle=self.rootNVDAObject.windowHandle,excelWindowObject=excelWindowObject,excelCellObject=cellPosition)
		else:
			obj=ExcelCell(windowHandle=self.rootNVDAObject.windowHandle,excelWindowObject=excelWindowObject,excelCellObject=cellPosition)
		cellPosition.Select()
		cellPosition.Activate()
		eventHandler.executeEvent('gainFocus',obj)
示例#46
0
	def navigationHelper(self,direction):
		excelWindowObject=self.rootNVDAObject.excelWindowObject
		cellPosition = excelWindowObject.activeCell
		try:
			if   direction == "left":
				cellPosition = cellPosition.Offset(0,-1)
			elif direction == "right":
				cellPosition = cellPosition.Offset(0,1)
			elif direction == "up":
				cellPosition = cellPosition.Offset(-1,0)
			elif direction == "down":
				cellPosition = cellPosition.Offset(1,0)
			#Start-of-Column
			elif direction == "startcol":
				cellPosition = cellPosition.end(xlUp)
			#Start-of-Row
			elif direction == "startrow":
				cellPosition = cellPosition.end(xlToLeft)
			#End-of-Row
			elif direction == "endrow":
				cellPosition = cellPosition.end(xlToRight)
			#End-of-Column
			elif direction == "endcol":
				cellPosition = cellPosition.end(xlDown)
			else:
				return
		except COMError:
			pass

		try:
			isMerged=cellPosition.mergeCells
		except (COMError,NameError):
			isMerged=False
		if isMerged:
			cellPosition=cellPosition.MergeArea(1)
			obj=ExcelMergedCell(windowHandle=self.rootNVDAObject.windowHandle,excelWindowObject=excelWindowObject,excelCellObject=cellPosition)
		else:
			obj=ExcelCell(windowHandle=self.rootNVDAObject.windowHandle,excelWindowObject=excelWindowObject,excelCellObject=cellPosition)
		cellPosition.Select()
		cellPosition.Activate()
		eventHandler.executeEvent('gainFocus',obj)
示例#47
0
文件: spotify.py 项目: yang123vc/nvda
 def event_gainFocus(self, obj, nextHandler):
     if not eventHandler.isPendingEvents(
             "gainFocus"
     ) and obj.windowClassName == "Chrome_WidgetWin_0" and obj.role == controlTypes.ROLE_WINDOW:
         # Spotify doesn't fire focus on the correct object when it gets the foreground.
         try:
             focus = obj.activeChild.activeChild
         except AttributeError:
             focus = None
         if focus:
             return eventHandler.executeEvent("gainFocus", focus)
     return nextHandler()
示例#48
0
 def _caretMovementScriptHelper(self, gesture, unit):
     try:
         info = self.makeTextInfo(textInfos.POSITION_CARET)
     except:
         gesture.send()
         return
     bookmark = info.bookmark
     gesture.send()
     caretMoved, newInfo = self._hasCaretMoved(bookmark)
     if not caretMoved and self.shouldFireCaretMovementFailedEvents:
         eventHandler.executeEvent("caretMovementFailed",
                                   self,
                                   gesture=gesture)
     if newInfo:
         i = newInfo.copy()
         i.expand(textInfos.UNIT_CHARACTER)
         t = i.text
         if t:
             o = ord(t[0])
             log.debug(repr([unit, t, ("%0x" % o)]))
     self._caretScriptPostMovedHelper(unit, gesture, newInfo)
示例#49
0
def handleInputCompositionEnd(result):
	import speech
	import characterProcessing
	from NVDAObjects.inputComposition import InputComposition
	from NVDAObjects.behaviors import CandidateItem
	focus=api.getFocusObject()
	result=result.lstrip(u'\u3000 ')
	curInputComposition=None
	if isinstance(focus,InputComposition):
		curInputComposition=focus
		oldSpeechMode=speech.speechMode
		speech.speechMode=speech.speechMode_off
		eventHandler.executeEvent("gainFocus",focus.parent)
		speech.speechMode=oldSpeechMode
	elif isinstance(focus.parent,InputComposition):
		#Candidate list is still up
		curInputComposition=focus.parent
		focus.parent=focus.parent.parent
	if curInputComposition and not result:
		result=curInputComposition.compositionString.lstrip(u'\u3000 ')
	if result:
		speech.speakText(result,symbolLevel=characterProcessing.SYMLVL_ALL)
示例#50
0
文件: NVDAHelper.py 项目: bramd/nvda
def handleInputCompositionEnd(result):
	import speech
	import characterProcessing
	from NVDAObjects.inputComposition import InputComposition
	from NVDAObjects.behaviors import CandidateItem
	focus=api.getFocusObject()
	result=result.lstrip(u'\u3000 ')
	curInputComposition=None
	if isinstance(focus,InputComposition):
		curInputComposition=focus
		oldSpeechMode=speech.speechMode
		speech.speechMode=speech.speechMode_off
		eventHandler.executeEvent("gainFocus",focus.parent)
		speech.speechMode=oldSpeechMode
	elif isinstance(focus.parent,InputComposition):
		#Candidate list is still up
		curInputComposition=focus.parent
		focus.parent=focus.parent.parent
	if curInputComposition and not result:
		result=curInputComposition.compositionString.lstrip(u'\u3000 ')
	if result:
		speech.speakText(result,symbolLevel=characterProcessing.SYMLVL_ALL)
示例#51
0
	def event_gainFocus(self, obj, nextHandler):
		if not eventHandler.isPendingEvents("gainFocus") and obj.windowClassName == "Chrome_WidgetWin_0" and obj.role == controlTypes.Role.WINDOW:
			# Spotify doesn't fire focus on the correct object when it gets the foreground.
			# Instead, it fires focus on a window ancestor.
			# Try to get the correct focus.
			try:
				focus = obj.firstChild.firstChild.activeChild
			except AttributeError:
				focus = None
			if focus:
				# Bounce focus to the correct object.
				return eventHandler.executeEvent("gainFocus", focus)
		return nextHandler()
示例#52
0
def handleInputCompositionEnd(result):
    import speech
    import characterProcessing
    from NVDAObjects.inputComposition import InputComposition
    from NVDAObjects.IAccessible.mscandui import ModernCandidateUICandidateItem
    focus = api.getFocusObject()
    result = result.lstrip(u'\u3000 ')
    curInputComposition = None
    if isinstance(focus, InputComposition):
        curInputComposition = focus
        oldSpeechMode = speech.getState().speechMode
        speech.setSpeechMode(speech.SpeechMode.off)
        eventHandler.executeEvent("gainFocus", focus.parent)
        speech.setSpeechMode(oldSpeechMode)
    elif isinstance(focus.parent, InputComposition):
        #Candidate list is still up
        curInputComposition = focus.parent
        focus.parent = focus.parent.parent
    if isinstance(focus, ModernCandidateUICandidateItem):
        # Correct focus for ModernCandidateUICandidateItem
        # Find the InputComposition object and
        # correct focus to its parent
        if isinstance(focus.container, InputComposition):
            curInputComposition = focus.container
            newFocus = curInputComposition.parent
        else:
            # Sometimes InputCompositon object is gone
            # Correct to container of CandidateItem
            newFocus = focus.container
        oldSpeechMode = speech.getState().speechMode
        speech.setSpeechMode(speech.SpeechMode.off)
        eventHandler.executeEvent("gainFocus", newFocus)
        speech.setSpeechMode(oldSpeechMode)

    if curInputComposition and not result:
        result = curInputComposition.compositionString.lstrip(u'\u3000 ')
    if result:
        speech.speakText(result,
                         symbolLevel=characterProcessing.SymbolLevel.ALL)
def handleInputCompositionStart(compositionString,selectionStart,selectionEnd,isReading):
	import speech
	from NVDAObjects.inputComposition import InputComposition
	from NVDAObjects.behaviors import CandidateItem
	focus=api.getFocusObject()
	if focus.parent and isinstance(focus.parent,InputComposition):
		#Candidates infront of existing composition string
		announce=not config.conf["inputComposition"]["announceSelectedCandidate"]
		focus.parent.compositionUpdate(compositionString,selectionStart,selectionEnd,isReading,announce=announce)
		return 0
	#IME keeps updating input composition while the candidate list is open
	#Therefore ignore new composition updates if candidate selections are configured for speaking.
	if config.conf["inputComposition"]["announceSelectedCandidate"] and isinstance(focus,CandidateItem):
		return 0
	if not isinstance(focus,InputComposition):
		parent=api.getDesktopObject().objectWithFocus()
		curInputComposition=InputComposition(parent=parent)
		oldSpeechMode=speech.speechMode
		speech.speechMode=speech.speechMode_off
		eventHandler.executeEvent("gainFocus",curInputComposition)
		focus=curInputComposition
		speech.speechMode=oldSpeechMode
	focus.compositionUpdate(compositionString,selectionStart,selectionEnd,isReading)
示例#54
0
def executeMouseMoveEvent(x,y):
	global currentMouseWindow
	desktopObject=api.getDesktopObject()
	screenLeft,screenTop,screenWidth,screenHeight=desktopObject.location
	x=min(max(screenLeft,x),(screenLeft+screenWidth)-1)
	y=min(max(screenTop,y),(screenTop+screenHeight)-1)
	if config.conf["mouse"]["audioCoordinatesOnMouseMove"]:
		playAudioCoordinates(x,y,screenWidth,screenHeight,config.conf['mouse']['audioCoordinates_detectBrightness'],config.conf['mouse']['audioCoordinates_blurFactor'])
	oldMouseObject=api.getMouseObject()
	mouseObject=desktopObject.objectFromPoint(x,y)
	while mouseObject and mouseObject.beTransparentToMouse:
		mouseObject=mouseObject.parent
	if not mouseObject:
		return
	if oldMouseObject==mouseObject:
		mouseObject=oldMouseObject
	else:
		api.setMouseObject(mouseObject)
	try:
		eventHandler.executeEvent("mouseMove",mouseObject,x=x,y=y)
		oldMouseObject=mouseObject
	except:
		log.error("api.notifyMouseMoved", exc_info=True)
示例#55
0
def executeMouseMoveEvent(x,y):
	global currentMouseWindow
	desktopObject=api.getDesktopObject()
	screenLeft,screenTop,screenWidth,screenHeight=desktopObject.location
	x=min(max(screenLeft,x),(screenLeft+screenWidth)-1)
	y=min(max(screenTop,y),(screenTop+screenHeight)-1)
	if config.conf["mouse"]["audioCoordinatesOnMouseMove"]:
		playAudioCoordinates(x,y,screenWidth,screenHeight,config.conf['mouse']['audioCoordinates_detectBrightness'],config.conf['mouse']['audioCoordinates_blurFactor'])
	oldMouseObject=api.getMouseObject()
	mouseObject=desktopObject.objectFromPoint(x,y)
	while mouseObject and mouseObject.beTransparentToMouse:
		mouseObject=mouseObject.parent
	if not mouseObject:
		return
	if oldMouseObject==mouseObject:
		mouseObject=oldMouseObject
	else:
		api.setMouseObject(mouseObject)
	try:
		eventHandler.executeEvent("mouseMove",mouseObject,x=x,y=y)
		oldMouseObject=mouseObject
	except:
		log.error("api.notifyMouseMoved", exc_info=True)
示例#56
0
文件: api.py 项目: zstanecic/nvda
def setNavigatorObject(obj: NVDAObjects.NVDAObject,
                       isFocus: bool = False) -> Optional[bool]:
    """Sets an object to be the current navigator object.
	Navigator objects can be used to navigate around the operating system (with the numpad),
	without moving the focus.
	It also sets the current review position to None so that next time the review position is asked for,
	it is created from the navigator object.
	@param obj: the object that will be set as the current navigator object
	@param isFocus: true if the navigator object was set due to a focus change.
	"""

    if not isinstance(obj, NVDAObjects.NVDAObject):
        return False
    if _isSecureObjectWhileLockScreenActivated(obj):
        return False
    globalVars.navigatorObject = obj
    globalVars.reviewPosition = None
    globalVars.reviewPositionObj = None
    reviewMode = review.getCurrentMode()
    # #3320: If in document review yet there is no document to review the mode should be forced to object.
    if reviewMode == 'document' and (
            not isinstance(obj.treeInterceptor,
                           treeInterceptorHandler.DocumentTreeInterceptor)
            or not obj.treeInterceptor.isReady
            or obj.treeInterceptor.passThrough):
        review.setCurrentMode('object', False)
    elif isinstance(
            obj.treeInterceptor, treeInterceptorHandler.DocumentTreeInterceptor
    ) and obj.treeInterceptor.isReady and not obj.treeInterceptor.passThrough:
        if reviewMode == 'object':
            review.setCurrentMode('document', False)
        if isFocus:
            globalVars.reviewPosition = obj.treeInterceptor.makeTextInfo(
                textInfos.POSITION_CARET)
            globalVars.reviewPositionObj = globalVars.reviewPosition
    eventHandler.executeEvent("becomeNavigatorObject", obj, isFocus=isFocus)
 def _caretMovementScriptHelper(self, gesture, unit):
     try:
         info = self.makeTextInfo(textInfos.POSITION_CARET)
     except Exception:
         gesture.send()
         return
     bookmark = info.bookmark
     curLevel = config.conf["speech"]["symbolLevel"]
     if unit == textInfos.UNIT_WORD:
         from ..settings.nvdaConfig import _NVDAConfigManager
         symbolLevelOnWordCaretMovement = _NVDAConfigManager.getSymbolLevelOnWordCaretMovement(
         )
         if symbolLevelOnWordCaretMovement is not None:
             config.conf["speech"][
                 "symbolLevel"] = symbolLevelOnWordCaretMovement
     gesture.send()
     caretMoved, newInfo = self._hasCaretMoved(bookmark)
     if not caretMoved and self.shouldFireCaretMovementFailedEvents:
         eventHandler.executeEvent("caretMovementFailed",
                                   self,
                                   gesture=gesture)
     reportPosition(newInfo)
     self._caretScriptPostMovedHelper(unit, gesture, newInfo)
     config.conf["speech"]["symbolLevel"] = curLevel
示例#58
0
def handleInputCandidateListUpdate(candidatesString, selectionIndex,
                                   inputMethod):
    log.debug(u"(%s) (%s) (%s)" % (unicode(candidatesString).replace(
        '\n', '|'), str(selectionIndex), unicode(inputMethod)))
    candidateStrings = candidatesString.split('\n')
    import speech
    from NVDAObjects.inputComposition import InputComposition, CandidateList, CandidateItem
    focus = api.getFocusObject()
    #nvdajp begin
    if config.conf["keyboard"]["nvdajpEnableKeyEvents"]:
        from NVDAObjects import inputComposition
        if inputComposition.lastKeyGesture:
            log.debug("lastKeyCode %x" %
                      inputComposition.lastKeyGesture.vkCode)
        if not inputComposition.needDiscriminantReading(
                inputComposition.lastKeyGesture):
            if isinstance(focus, CandidateItem):
                oldSpeechMode = speech.speechMode
                speech.speechMode = speech.speechMode_off
                eventHandler.executeEvent("gainFocus", focus.parent)
                speech.speechMode = oldSpeechMode
            return
    #nvdajp end
    if not (0 <= selectionIndex < len(candidateStrings)):
        if isinstance(focus, CandidateItem):
            oldSpeechMode = speech.speechMode
            speech.speechMode = speech.speechMode_off
            eventHandler.executeEvent("gainFocus", focus.parent)
            speech.speechMode = oldSpeechMode
        return
    oldCandidateItemsText = None
    if isinstance(focus, CandidateItem):
        oldCandidateItemsText = focus.visibleCandidateItemsText
        parent = focus.parent
        wasCandidate = True
    else:
        parent = focus
        wasCandidate = False
    item = CandidateItem(parent=parent,
                         candidateStrings=candidateStrings,
                         candidateIndex=selectionIndex,
                         inputMethod=inputMethod)
    if wasCandidate and focus.windowHandle == item.windowHandle and focus.candidateIndex == item.candidateIndex and focus.name == item.name:
        return
    if config.conf["inputComposition"][
            "autoReportAllCandidates"] and item.visibleCandidateItemsText != oldCandidateItemsText:
        import ui
        ui.message(item.visibleCandidateItemsText)
    eventHandler.executeEvent("gainFocus", item)
示例#59
0
	def event_selection(self):
		if self.parent.hasFocus and api.getFocusObject() != self:
			eventHandler.executeEvent("gainFocus", self)