コード例 #1
0
def initialize():
	global curMousePos
	(x,y)=winUser.getCursorPos()
	desktopObject=api.getDesktopObject()
	try:
		mouseObject=desktopObject.objectFromPoint(x,y)
	except:
		log.exception("Error retrieving initial mouse object")
		mouseObject=None
	if not mouseObject:
		mouseObject=api.getDesktopObject()
	api.setMouseObject(mouseObject)
	curMousePos=(x,y)
	winInputHook.initialize()
	winInputHook.setCallbacks(mouse=internal_mouseEvent)
コード例 #2
0
def limitRectInDesktop(newRect):
	l, t, w, h = api.getDesktopObject().location
	newRect.top = max(0, newRect.top)
	newRect.left = max(0, newRect.left)
	newRect.right = max(0, min(l+w, newRect.right))
	newRect.bottom = max(0, min(t+h, newRect.bottom))
	return newRect
コード例 #3
0
	def _get_parent(self):
		#hack: This code should be taken out once the crash is fixed in Adobe Reader X.
		#If going parent on a root text node after saying ok to the accessibility options (untagged) and before the processing document dialog appears, Reader X will crash.
		if self.event_childID==0:
			return api.getDesktopObject()
		else:
			return super(AcrobatTextNode,self).parent
コード例 #4
0
    def jumpToPosition(self):
        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mouseJumpHelper = gui.guiHelper.BoxSizerHelper(self,
                                                       orientation=wx.VERTICAL)

        x, y = winUser.getCursorPos()
        w, h = api.getDesktopObject().location[2:]
        self.xPos = mouseJumpHelper.addLabeledControl(
            _("&X position"),
            gui.nvdaControls.SelectOnFocusSpinCtrl,
            min=0,
            max=w - 1,
            initial=x)
        self.yPos = mouseJumpHelper.addLabeledControl(
            _("&Y position"),
            gui.nvdaControls.SelectOnFocusSpinCtrl,
            min=0,
            max=h - 1,
            initial=y)

        mouseJumpHelper.addDialogDismissButtons(
            self.CreateButtonSizer(wx.OK | wx.CANCEL))
        self.Bind(wx.EVT_BUTTON, self.onOk, id=wx.ID_OK)
        self.Bind(wx.EVT_BUTTON, self.onCancel, id=wx.ID_CANCEL)
        mainSizer.Add(mouseJumpHelper.sizer,
                      border=gui.guiHelper.BORDER_FOR_DIALOGS,
                      flag=wx.ALL)
        mainSizer.Fit(self)
        self.SetSizer(mainSizer)
        self.Center(wx.BOTH | wx.Center)
        self.xPos.SetFocus()
コード例 #5
0
ファイル: vlc.py プロジェクト: javidominguez/VLC
 def chooseNVDAObjectOverlayClasses(self, obj, clsList):
     if obj.role == controlTypes.Role.APPLICATION:
         obj.parent = api.getDesktopObject()
         clsList.insert(0, VLC_application)
     if obj.windowClassName == u'Qt5QWindowIcon':
         if obj.role == controlTypes.Role.BORDER or obj.role == controlTypes.Role.PANE:
             if obj.childCount == 3:
                 if obj.lastChild.role == controlTypes.Role.STATICTEXT:
                     obj.role = controlTypes.Role.STATUSBAR
                     clsList.insert(0, VLC_StatusBar)
                 elif obj.lastChild and obj.lastChild.firstChild and obj.lastChild.firstChild.firstChild\
                 and obj.lastChild.firstChild.firstChild.role == controlTypes.Role.MENUBUTTON:
                     obj.role = controlTypes.Role.PANEL
                     #TRANSLATORS: Title of the panel that contains the playlist when it is inside main window
                     obj.name = _("Playlist")
                     obj.isPresentableFocusAncestor = False
                     clsList.insert(0, VLC_AnchoredPlaylist)
             else:
                 obj.role = controlTypes.Role.LAYEREDPANE
                 if obj.windowText in self.embeddedWindows:
                     obj.name = self.embeddedWindows[obj.windowText]
                 elif api.getForegroundObject() and api.getForegroundObject(
                 ).name and obj.windowText != api.getForegroundObject(
                 ).name:
                     obj.description = obj.windowText
                 clsList.insert(0, VLC_pane)
         elif obj.role == controlTypes.Role.WINDOW:
             if obj.firstChild and obj.firstChild.role == controlTypes.Role.MENUBAR:
                 clsList.insert(0, VLC_mainWindow)
             elif obj.windowStyle == 1442840576:
                 if obj.windowText in self.embeddedWindows:
                     obj.name = self.embeddedWindows[obj.windowText]
                     obj.isPresentableFocusAncestor = True
                 else:
                     obj.description = obj.windowText
                 clsList.insert(0, VLC_EmbeddedWindow)
         elif obj.windowStyle == -1764884480 and obj.isFocusable:
             try:
                 container = obj.container.container.container.container
             except AttributeError:
                 pass
             else:
                 if container and container.name and container.role == controlTypes.Role.LAYEREDPANE:
                     if obj.previous and obj.previous.role == controlTypes.Role.STATICTEXT:
                         obj.name = obj.previous.name
                     clsList.insert(0, VLC_mediaInfo)
     if obj.role == controlTypes.Role.SPINBUTTON:
         clsList.insert(0, VLC_spinButton)
     if obj.role == controlTypes.Role.DIALOG and (
             obj.windowClassName == u'Qt5QWindowToolSaveBits'
             or obj.windowClassName == u'Qt5QWindowIcon'):
         clsList.insert(0, VLC_Dialog)
     if obj.role == controlTypes.Role.LISTITEM and obj.windowText == u'StandardPLPanelClassWindow':
         clsList.insert(0, VLC_PlaylistItem)
     if obj.role == controlTypes.Role.EDITABLETEXT and (
             obj.windowClassName == u'Qt5QWindowIcon'
             or obj.simpleParent.role == 20):  #@ dev: add edit bookmarks
         # obj.typeBuffer = ""
         # obj.fakeCaret = len(obj.value)-1 if obj.value else 0
         clsList.insert(0, VLC_EditableText)
コード例 #6
0
def getSizeAndPosition(descendant, ancestor):
    # The relative parent isn't an ancestor of the descendant.
    if descendant and not isFocusAncestor(ancestor) and hasLocation(
            descendant):
        dtk = list(
            filter(
                lambda p: isinstance(
                    p, globalPluginHandler.globalPlugins.developerToolkit.
                    GlobalPlugin), globalPluginHandler.runningPlugins))[0]
        dtk.relativeParent = api.getDesktopObject()
        return {
            'left': descendant.location.left,
            'top': descendant.location.top,
            'right': descendant.location.right,
            'bottom': descendant.location.bottom,
            'bottom-bottom':
            ancestor.location.bottom - descendant.location.bottom,
            'right-right': ancestor.location.right - descendant.location.right,
            'height': descendant.location.height,
            'width': descendant.location.width,
        }
    # The relative parent is an ancestor of the descendant.
    if descendant and isFocusAncestor(ancestor) and hasLocation(descendant):
        return {
            'left': descendant.location.left - ancestor.location.left,
            'top': descendant.location.top - ancestor.location.top,
            'right': descendant.location.right - ancestor.location.left,
            'bottom': descendant.location.bottom - ancestor.location.top,
            'bottom-bottom':
            ancestor.location.bottom - descendant.location.bottom,
            'right-right': ancestor.location.right - descendant.location.right,
            'height': descendant.location.height,
            'width': descendant.location.width,
        }
コード例 #7
0
def getDesktopChildObj(windowClassName):
    o = api.getDesktopObject().firstChild
    while o:
        if o.windowClassName == windowClassName:
            return o
        o = o.next
    return None
コード例 #8
0
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)
コード例 #9
0
ファイル: nvda.py プロジェクト: KarishmaChanglani/nvda
	def event_NVDAObject_init(self, obj):
		# It seems that context menus always get the name "context" and this cannot be overridden.
		# Fudge the name of the NVDA system tray menu to make it more friendly.
		if obj.role == controlTypes.ROLE_POPUPMENU:
			parent = obj.parent
			if parent and parent.parent==api.getDesktopObject():
				obj.name=versionInfo.name
コード例 #10
0
def initialize():
	global curMousePos, scrBmpObj
	scrBmpObj=screenBitmap.ScreenBitmap(1,1)
	(x,y)=winUser.getCursorPos()
	desktopObject=api.getDesktopObject()
	try:
		mouseObject=desktopObject.objectFromPoint(x,y)
	except:
		log.exception("Error retrieving initial mouse object")
		mouseObject=None
	if not mouseObject:
		mouseObject=api.getDesktopObject()
	api.setMouseObject(mouseObject)
	curMousePos=(x,y)
	winInputHook.initialize()
	winInputHook.setCallbacks(mouse=internal_mouseEvent)
コード例 #11
0
def obtainUWPWindowText():
    foreground = api.getForegroundObject()
    desktop = api.getDesktopObject()
    uwpTextList = [foreground.name]
    curObject = foreground.firstChild
    while curObject:
        if curObject.name is not None: uwpTextList.append(curObject.name)
        if curObject.simpleFirstChild:
            curObject = curObject.simpleFirstChild
            continue
        if curObject.simpleNext:
            curObject = curObject.simpleNext
            continue
        if curObject.simpleParent:
            parent = curObject.simpleParent
            # As long as one is on current foreground object...
            #Stay within the current top-level window.
            if parent.simpleParent == desktop:
                break
            while parent and not parent.simpleNext:
                parent = parent.simpleParent
            # But sometimes, the top-level window has no sibling at all (such is the case in Windows 10 Start menu).
            try:
                curObject = parent.simpleNext
            except AttributeError:
                continue
    return uwpTextList
コード例 #12
0
def executeMouseMoveEvent(x, y):
    global currentMouseWindow
    desktopObject = api.getDesktopObject()
    displays = [
        wx.Display(i).GetGeometry() for i in range(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)
コード例 #13
0
ファイル: jumpToWindow.py プロジェクト: ctoth/jumpToWindow
	def find(self, text):
		"""Find a window with the supplied text in its title.
		If the text isn't found in any title, search the text of consoles."""
		consoles = set()
		text = text.lower()
		for c in api.getDesktopObject().children:
			name = c.name
			if name is None:
				continue
			if text in name.lower():
				focus(c.windowHandle)
				return
			elif c.windowClassName == u'ConsoleWindowClass':
				consoles.add(c)

		#We didn't find the search text in the title, start searching consoles
		current_console = winConsoleHandler.consoleObject
		# If our current console is the one with the text in it, presumably we want another one, and if one isn't found, we'll refocus anyway
		if current_console is not None:
			consoles.remove(current_console)
		for console in consoles:
			#We assume this can't fail
			console_text = get_console_text(console)
			if text in console_text.lower():
				focus(console.windowHandle)
				return
		else: #No consoles found
			if current_console:
				winConsoleHandler.connectConsole(current_console)
				if current_console == api.getFocusObject():
					current_console.startMonitoring() #Keep echoing if we didn't switch
		tones.beep(300, 150)
コード例 #14
0
ファイル: thunderbird.py プロジェクト: jmdaweb/MozillaScripts
 def dragAndDrop(self, hIndex1, hIndex2):
     if self.columns[0].windowText != self.folder:
         #TRANSLATORS: the folder content has changed while this dialog was opened
         ui.message(
             _("Folder has changed, return to %s to manage columns or restart this dialog"
               ) % self.folder[:-22])
         return False
     self.Hide()
     try:
         x = self.columns[hIndex1].location[
             0] + self.columns[hIndex1].location[2] / 2
         y = self.columns[hIndex1].location[
             1] + self.columns[hIndex1].location[3] / 2
     except TypeError:
         return False
     if api.getDesktopObject().objectFromPoint(x,
                                               y) != self.columns[hIndex1]:
         return False
     winUser.setCursorPos(x, y)
     if winUser.getKeyState(winUser.VK_LBUTTON) & 32768:
         winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None)
     winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 1, None, None)
     x = self.columns[hIndex2].location[0] + self.columns[hIndex2].location[
         2] + 1
     y = self.columns[hIndex2].location[
         1] + self.columns[hIndex2].location[3] / 2
     winUser.setCursorPos(x, y)
     winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None)
     tmp = self.columns[hIndex1]
     self.columns[hIndex1] = self.columns[hIndex2]
     self.columns[hIndex2] = tmp
     self.update()
     return True
コード例 #15
0
ファイル: eventHandler.py プロジェクト: rmalunda/nvda
def doPreGainFocus(obj, sleepMode=False):
    oldForeground = api.getForegroundObject()
    oldFocus = api.getFocusObject()
    oldTreeInterceptor = oldFocus.treeInterceptor if oldFocus else None
    api.setFocusObject(obj)
    if globalVars.focusDifferenceLevel <= 1:
        newForeground = api.getDesktopObject().objectInForeground()
        if not newForeground:
            log.debugWarning(
                "Can not get real foreground, resorting to focus ancestors")
            ancestors = api.getFocusAncestors()
            if len(ancestors) > 1:
                newForeground = ancestors[1]
            else:
                newForeground = obj
        api.setForegroundObject(newForeground)
        executeEvent('foreground', newForeground)
    if sleepMode: return True
    #Fire focus entered events for all new ancestors of the focus if this is a gainFocus event
    for parent in globalVars.focusAncestors[globalVars.focusDifferenceLevel:]:
        executeEvent("focusEntered", parent)
    if obj.treeInterceptor is not oldTreeInterceptor:
        if hasattr(oldTreeInterceptor, "event_treeInterceptor_loseFocus"):
            oldTreeInterceptor.event_treeInterceptor_loseFocus()
        if obj.treeInterceptor and obj.treeInterceptor.isReady and hasattr(
                obj.treeInterceptor, "event_treeInterceptor_gainFocus"):
            obj.treeInterceptor.event_treeInterceptor_gainFocus()
    return True
コード例 #16
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)
コード例 #17
0
 def moveMouse(self, direction):
     w, h = api.getDesktopObject().location[2:]
     x, y = winUser.getCursorPos()
     oldX, oldY = x, y
     pixelMoving = config.conf["goldenCursor"]["mouseMovementUnit"]
     if direction == GCMouseRight: x += pixelMoving
     elif direction == GCMouseLeft: x -= pixelMoving
     elif direction == GCMouseDown: y += pixelMoving
     elif direction == GCMouseUp: y -= pixelMoving
     # Just do a chain comparison, as it is a lot faster.
     if 0 <= x < w and 0 <= y < h:
         setMousePosition(x, y)
     else:
         wx.Bell()
         return
     if self.restriction and self.getAppRestriction.appModule.appName != self.getMouse(
     ).appModule.appName:
         wx.Bell()
         setMousePosition(oldX, oldY)
         if self.getAppRestriction.appModule.appName != self.getMouse(
         ).appModule.appName:
             x, y, w, h = self.getAppRestriction.location
             setMousePosition(x, y)
         return
     if config.conf["goldenCursor"]["reportNewMouseCoordinates"]:
         ui.message(
             str(x if direction in (GCMouseRight, GCMouseLeft) else y))
コード例 #18
0
ファイル: NVDAHelper.py プロジェクト: werwoelfchen/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()
        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)
コード例 #19
0
 def showGui(self):
     # The menu pops up at the location of the mouse, which means it pops up at an unpredictable location.
     # Therefore, move the mouse to the center of the screen so that the menu will always pop up there.
     location = api.getDesktopObject().location
     winUser.setCursorPos(*location.center)
     self.evaluateUpdatePendingUpdateMenuItemCommand()
     self.sysTrayIcon.onActivate(None)
コード例 #20
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)
コード例 #21
0
ファイル: winword.py プロジェクト: xinyi-joffre/nvda
 def focusOnActiveDocument(self, officeChartObject):
     rangeStart = officeChartObject.Parent.Range.Start
     self.WinwordApplicationObject.ActiveDocument.Range(
         rangeStart, rangeStart).Select()
     import api
     eventHandler.executeEvent("gainFocus",
                               api.getDesktopObject().objectWithFocus())
コード例 #22
0
 def script_settings(self, gesture):
     try:
         tree = self.parent.recursiveDescendants
     except:
         raise RuntimeError("Unable to get the object tree")
         return
     obj = tree.__next__()
     while True:
         try:
             if obj.UIAElement.currentClassName == "QLabel":
                 winUser.setCursorPos(obj.location.left + 2,
                                      obj.location.top + 2)
                 if obj == api.getDesktopObject().objectFromPoint(
                         obj.location.left + 2, obj.location.top + 2):
                     winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 1,
                                         None, None)
                     winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 1,
                                         None, None)
                 else:
                     raise RuntimeError("Unable to click in settings label")
                 break
             obj = tree.__next__()
         except StopIteration:
             raise RuntimeError("Settings label not found")
             break
コード例 #23
0
def doPreGainFocus(obj,sleepMode=False):
	oldForeground=api.getForegroundObject()
	oldFocus=api.getFocusObject()
	oldTreeInterceptor=oldFocus.treeInterceptor if oldFocus else None
	api.setFocusObject(obj)
	if globalVars.focusDifferenceLevel<=1:
		newForeground=api.getDesktopObject().objectInForeground()
		if not newForeground:
			log.debugWarning("Can not get real foreground, resorting to focus ancestors")
			ancestors=api.getFocusAncestors()
			if len(ancestors)>1:
				newForeground=ancestors[1]
			else:
				newForeground=obj
		api.setForegroundObject(newForeground)
		executeEvent('foreground',newForeground)
	if sleepMode: return True
	#Fire focus entered events for all new ancestors of the focus if this is a gainFocus event
	for parent in globalVars.focusAncestors[globalVars.focusDifferenceLevel:]:
		executeEvent("focusEntered",parent)
	if obj.treeInterceptor is not oldTreeInterceptor:
		if hasattr(oldTreeInterceptor,"event_treeInterceptor_loseFocus"):
			oldTreeInterceptor.event_treeInterceptor_loseFocus()
		if obj.treeInterceptor and obj.treeInterceptor.isReady and hasattr(obj.treeInterceptor,"event_treeInterceptor_gainFocus"):
			obj.treeInterceptor.event_treeInterceptor_gainFocus()
	return True
コード例 #24
0
def limitRectInDesktop(newRect):
    l, t, w, h = api.getDesktopObject().location
    newRect.top = max(0, newRect.top)
    newRect.left = max(0, newRect.left)
    newRect.right = max(0, min(l + w, newRect.right))
    newRect.bottom = max(0, min(t + h, newRect.bottom))
    return newRect
コード例 #25
0
ファイル: mouseHandler.py プロジェクト: bramd/nvda
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)
コード例 #26
0
 def approbes(self, listEvent, logger):
     try:
         for event in reversed(listEvent):
             if isinstance(event, NavigationByKeyH):
                 ui.message("Objeto Foco")
                 (leftf, topf, widthf, heightf) = event.foco.location
                 speech.speakObject(event.foco)
                 ui.message("Objeto navegado")
                 (left, top, width, height) = event.navegado.location
                 ui.message("Absolutas")
                 (deskLeft, deskTop, deskWidth,
                  deskHeight) = api.getDesktopObject().location
                 speech.speakObject(event.navegado)
                 #finaltop=float(top-deskTop)
                 params = urllib.urlencode({
                     "threat":
                     "FlashScrolingKeyH",
                     "desktop": (deskLeft, deskTop, deskWidth, deskHeight),
                     "foco Location": (leftf, topf, widthf, heightf),
                     "finalTop":
                     "finaltop",
                     "locationNavegador": (left, top, width, height),
                     "timeStamp":
                     event.timeStamp,
                     "navegado":
                     event.navegado,
                     "url":
                     event.url
                 })
                 logger.logEven('NavigationByKeyH', params, False)
                 ui.message("enviando")
     except:
         ui.message("Error al  Procesar finder NavigationByKeyH")
コード例 #27
0
 def event_NVDAObject_init(self, obj):
     # It seems that context menus always get the name "context" and this cannot be overridden.
     # Fudge the name of the NVDA system tray menu to make it more friendly.
     if obj.role == controlTypes.ROLE_POPUPMENU:
         parent = obj.parent
         if parent and parent.parent == api.getDesktopObject():
             obj.name = versionInfo.name
コード例 #28
0
 def getDocName(self):
     # getting file path and name
     global docPath
     docPath = ""
     fg = api.getForegroundObject()
     # We check if we are in the Windows Explorer.
     if fg.role != api.controlTypes.Role.PANE and fg.appModule.appName != "explorer":
         return
     shell = COMCreate("shell.application")
     # We go through the list of open Windows Explorers to find the one that has the focus.
     for window in shell.Windows():
         try:
             if window.hwnd and window.hwnd == fg.windowHandle:
                 focusedItem = window.Document.FocusedItem
                 break
         except:
             pass
     else:  # loop exhausted
         desktop_path = os.path.join(
             os.path.join(os.environ['USERPROFILE']), 'Desktop')
         docPath = '\"' + desktop_path + '\\' + api.getDesktopObject(
         ).objectWithFocus().name + '\"'
         return
     # Now that we have the current folder, we can explore the SelectedItems collection.
     targetFile = focusedItem.path
     docPath = '\"' + str(targetFile) + '\"'
コード例 #29
0
ファイル: IAccessibleHandler.py プロジェクト: BabbageCom/nvda
def _fakeFocus(oldFocus):
	if oldFocus is not api.getFocusObject():
		# The focus has changed - no need to fake it.
		return
	focus = api.getDesktopObject().objectWithFocus()
	if not focus:
		return
	processFocusNVDAEvent(focus)
コード例 #30
0
	def initialFocus(self) -> None:
		"""Handles the current focus when the provider is initialized.
		This function notifies one or more extension points; thus it can raise any type of exception.
		"""
		if not api.getDesktopObject():
			# focus/review hasn't yet been initialized.
			return
		self.handleGainFocus(api.getFocusObject())
コード例 #31
0
ファイル: mouseHandler.py プロジェクト: bramd/nvda
def initialize():
	global curMousePos, scrBmpObj, _shapeTimer
	scrBmpObj=screenBitmap.ScreenBitmap(1,1)
	(x,y)=winUser.getCursorPos()
	desktopObject=api.getDesktopObject()
	try:
		mouseObject=desktopObject.objectFromPoint(x,y)
	except:
		log.exception("Error retrieving initial mouse object")
		mouseObject=None
	if not mouseObject:
		mouseObject=api.getDesktopObject()
	api.setMouseObject(mouseObject)
	curMousePos=(x,y)
	winInputHook.initialize()
	winInputHook.setCallbacks(mouse=internal_mouseEvent)
	_shapeTimer = gui.NonReEntrantTimer(_reportShape)
コード例 #32
0
def _fakeFocus(oldFocus):
    if oldFocus is not api.getFocusObject():
        # The focus has changed - no need to fake it.
        return
    focus = api.getDesktopObject().objectWithFocus()
    if not focus:
        return
    processFocusNVDAEvent(focus)
コード例 #33
0
ファイル: __init__.py プロジェクト: timothytylee/nvda
	def showGui(self):
		# The menu pops up at the location of the mouse, which means it pops up at an unpredictable location.
		# Therefore, move the mouse to the centre of the screen so that the menu will always pop up there.
		left, top, width, height = api.getDesktopObject().location
		x = width / 2
		y = height / 2
		winUser.setCursorPos(x, y)
		self.sysTrayIcon.onActivate(None)
コード例 #34
0
	def showGui(self):
		# The menu pops up at the location of the mouse, which means it pops up at an unpredictable location.
		# Therefore, move the mouse to the centre of the screen so that the menu will always pop up there.
		left, top, width, height = api.getDesktopObject().location
		x = width / 2
		y = height / 2
		winUser.setCursorPos(x, y)
		self.sysTrayIcon.onActivate(None)
コード例 #35
0
 def playPoint(self, x, y):
     if not self.imagePlayer: return
     screenWidth, screenHeight = api.getDesktopObject().location[2:]
     width = self.screenBitmap.width
     height = self.screenBitmap.height
     x = x - (width / 2)
     y = y - (height / 2)
     self.playRect(x, y, width, height)
コード例 #36
0
	def initialNavigatorObject(self) -> None:
		"""Handles the current navigator object when the provider is initialized.
		This function notifies an extension point; thus it can raise any type of exception.
		"""
		if not api.getDesktopObject():
			# focus/review hasn't yet been initialized.
			return
		self.handleReviewMove(context=Context.REVIEW)
コード例 #37
0
ファイル: __init__.py プロジェクト: nvaccess/audioScreen
	def playPoint(self,x,y):
		if not self.imagePlayer: return
		screenWidth,screenHeight=api.getDesktopObject().location[2:]
		width=self.screenBitmap.width
		height=self.screenBitmap.height
		x=x-(width/2)
		y=y-(height/2)
		self.playRect(x,y,width,height)
コード例 #38
0
ファイル: DragAndDrop.py プロジェクト: cary-rowen/DragAndDrop
 def script_dropLeft(self, gesture):
     obj = api.getNavigatorObject()
     if obj.location == (0, 0, 0, 0) or controlTypes.STATE_INVISIBLE in obj.states or controlTypes.STATE_OFFSCREEN in obj.states \
     or api.getDesktopObject().objectFromPoint(obj.location[0]+1, obj.location[1]+1) != obj:
         self.error(_("Can't drop here"))
         return
     x = obj.location[0] - 1
     y = obj.location[1] + obj.location[3] / 2
     self.dragAndDrop(x, y)
コード例 #39
0
		def callback():
			obj = api.getDesktopObject().firstChild
			while obj is not None:
				if obj.role == controlTypes.ROLE_WINDOW and\
					obj.windowClassName == u'Qt5QWindowToolSaveBits':
					obj.setFocus()
					api.setFocusObject(obj)
					break
				obj = obj.next
コード例 #40
0
ファイル: displayModel.py プロジェクト: sonar-gnu-linux/nvda
	def _getNVDAObjectFromOffset(self,offset):
		try:
			p=self._getPointFromOffset(offset)
		except (NotImplementedError,LookupError):
			return self.obj
		obj=api.getDesktopObject().objectFromPoint(p.x,p.y)
		from NVDAObjects.window import Window
		if not obj or not isinstance(obj,Window) or not winUser.isDescendantWindow(self.obj.windowHandle,obj.windowHandle):
			return self.obj
		return obj
コード例 #41
0
	def setUp(self):
		"""Set up a fake focus object and give it some ancestry."""
		self.obj=NVDAObjectWithRole(role=controlTypes.ROLE_LISTITEM)
		# Forcefully create a fake focus ancestry
		# Note that the braille code excludes the desktop object when getting regions for focus ancestry
		# The resulting focus object including ancestry will look like: "dialog dlg list lst list item"
		globalVars.focusAncestors=[api.getDesktopObject(),NVDAObjectWithRole(role=controlTypes.ROLE_DIALOG),NVDAObjectWithRole(role=controlTypes.ROLE_LIST)]
		braille.handler.handleGainFocus(self.obj)
		# Make sure that we are testing with three regions
		self.assertEqual(len(self.regionsWithPositions),3)
コード例 #42
0
ファイル: test_braille.py プロジェクト: MarcoZehe/nvda
	def setUp(self):
		"""Set up a fake focus object and give it some ancestry."""
		self.obj=NVDAObjectWithRole(role=controlTypes.ROLE_LISTITEM)
		# Forcefully create a fake focus ancestry
		# Note that the braille code excludes the desktop object when getting regions for focus ancestry
		# The resulting focus object including ancestry will look like: "dialog dlg list lst list item"
		globalVars.focusAncestors=[api.getDesktopObject(),NVDAObjectWithRole(role=controlTypes.ROLE_DIALOG),NVDAObjectWithRole(role=controlTypes.ROLE_LIST)]
		braille.handler.handleGainFocus(self.obj)
		# Make sure that we are testing with three regions
		self.assertEqual(len(self.regionsWithPositions),3)
コード例 #43
0
ファイル: calibre.py プロジェクト: javidominguez/Calibre
 def tbContextMenu(self, obj, func):
     api.setNavigatorObject(obj)
     x = obj.location[0] + 2
     y = obj.location[1] + 2
     winUser.setCursorPos(x, y)
     if api.getDesktopObject().objectFromPoint(x, y) == obj:
         scriptHandler.executeScript(func, None)
     else:
         # TRANSLATORS: Message shown when the object is not found
         ui.message(_("Not found"))
コード例 #44
0
ファイル: displayModel.py プロジェクト: davidacm/nvda
	def _getNVDAObjectFromOffset(self,offset):
		try:
			p=self._getPointFromOffset(offset)
		except (NotImplementedError,LookupError):
			return self.obj
		obj=api.getDesktopObject().objectFromPoint(p.x,p.y)
		from NVDAObjects.window import Window
		if not obj or not isinstance(obj,Window) or not winUser.isDescendantWindow(self.obj.windowHandle,obj.windowHandle):
			return self.obj
		return obj
コード例 #45
0
	def _get_locationText(self):
		"""A message that explains the location of the object in friendly terms."""
		location=self.location
		if not location:
			return None
		(left,top,width,height)=location
		deskLocation=api.getDesktopObject().location
		(deskLeft,deskTop,deskWidth,deskHeight)=deskLocation
		percentFromLeft=(float(left-deskLeft)/deskWidth)*100
		percentFromTop=(float(top-deskTop)/deskHeight)*100
		percentWidth=(float(width)/deskWidth)*100
		percentHeight=(float(height)/deskHeight)*100
		# Translators: Reports navigator object's dimensions (example output: object edges positioned 20 per cent from left edge of screen, 10 per cent from top edge of screen, width is 40 per cent of screen, height is 50 per cent of screen).
		return _("Object edges positioned {left:.1f} per cent from left edge of screen, {top:.1f} per cent from top edge of screen, width is {width:.1f} per cent of screen, height is {height:.1f} per cent of screen").format(left=percentFromLeft,top=percentFromTop,width=percentWidth,height=percentHeight)
コード例 #46
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")
コード例 #47
0
ファイル: maps.py プロジェクト: josephsl/wintenApps
	def event_becomeNavigatorObject(self):
		l,t,w,h=self.location
		x = l+(w/2)
		y = t+(h/2)
		screenWidth, screenHeight = api.getDesktopObject().location[2:]
		if x <= screenWidth or y <= screenHeight:
			minPitch=config.conf['mouse']['audioCoordinates_minPitch']
			maxPitch=config.conf['mouse']['audioCoordinates_maxPitch']
			curPitch=minPitch+((maxPitch-minPitch)*((screenHeight-y)/float(screenHeight)))
			brightness=config.conf['mouse']['audioCoordinates_maxVolume']
			leftVolume=int((85*((screenWidth-float(x))/screenWidth))*brightness)
			rightVolume=int((85*(float(x)/screenWidth))*brightness)
			tones.beep(curPitch,40,left=leftVolume,right=rightVolume)
		super(MapLocation,self).event_becomeNavigatorObject()
コード例 #48
0
ファイル: eclipse.py プロジェクト: ehollig/nvda
	def chooseNVDAObjectOverlayClasses(self, obj, clsList):
		if obj.windowClassName == "SWT_Window0" and obj.role == controlTypes.ROLE_EDITABLETEXT:
			clsList.insert(0, EclipseTextArea)

		try:

			# Autocompletion items are placed outside the main eclipse window
			if (obj.role == controlTypes.ROLE_LISTITEM
				and obj.parent.parent.parent.role == controlTypes.ROLE_DIALOG
				and obj.parent.parent.parent.parent.parent == api.getDesktopObject()
				and obj.parent.parent.parent.parent.simpleNext.role == controlTypes.ROLE_BUTTON):
				clsList.insert(0, AutocompletionListItem)
		except:
			pass
コード例 #49
0
ファイル: braille.py プロジェクト: atsuoishimoto/tweetitloud
def initialize():
	global handler
	config.addConfigDirsToPythonPackagePath(brailleDisplayDrivers)
	log.info("Using liblouis version %s" % louis.version())
	handler = BrailleHandler()
	handler.setDisplayByName(config.conf["braille"]["display"])

	# Update the display to the current focus/review position.
	if not handler.enabled or not api.getDesktopObject():
		# Braille is disabled or focus/review hasn't yet been initialised.
		return
	if handler.tether == handler.TETHER_FOCUS:
		handler.handleGainFocus(api.getFocusObject())
	else:
		handler.handleReviewMove()
コード例 #50
0
ファイル: screenExplorer.py プロジェクト: Alain-Ambazac/nvda
	def moveTo(self,x,y,new=False,unit=textInfos.UNIT_LINE):
		obj=api.getDesktopObject().objectFromPoint(x,y)
		prevObj=None
		while obj  and obj.beTransparentToMouse:
			prevObj=obj
			obj=obj.parent
		if not obj or (obj.presentationType!=obj.presType_content and obj.role!=controlTypes.ROLE_PARAGRAPH):
			obj=prevObj
		if not obj:
			return
		hasNewObj=False
		if obj!=self._obj:
			self._obj=obj
			hasNewObj=True
			if self.updateReview:
				api.setNavigatorObject(obj)
		else:
			obj=self._obj
		pos=None
		if obj.treeInterceptor:
			try:
				pos=obj.treeInterceptor.makeTextInfo(obj)
			except LookupError:
				pos=None
			if pos:
				obj=obj.treeInterceptor.rootNVDAObject
				if hasNewObj and self._obj and obj.treeInterceptor is self._obj.treeInterceptor:
					hasNewObj=False 
		if not pos:
			try:
				pos=obj.makeTextInfo(textInfos.Point(x,y))
			except (NotImplementedError,LookupError):
				pass
			if pos: pos.expand(unit)
		if pos and self.updateReview:
			api.setReviewPosition(pos)
		speechCanceled=False
		if hasNewObj:
			speech.cancelSpeech()
			speechCanceled=True
			speech.speakObject(obj)
		if pos  and (new or not self._pos or pos.__class__!=self._pos.__class__ or pos.compareEndPoints(self._pos,"startToStart")!=0 or pos.compareEndPoints(self._pos,"endToEnd")!=0):
				self._pos=pos
				if not speechCanceled:
					speech.cancelSpeech()
				speech.speakTextInfo(pos,reason=controlTypes.REASON_CARET)
コード例 #51
0
	def script_navigatorObject_currentDimensions(self,gesture):
		obj=api.getNavigatorObject()
		if not obj:
			ui.message(_("no navigator object"))
		location=obj.location
		if not location:
			ui.message(_("No location information for navigator object"))
		(left,top,width,height)=location
		deskLocation=api.getDesktopObject().location
		if not deskLocation:
			ui.message(_("No location information for screen"))
		(deskLeft,deskTop,deskWidth,deskHeight)=deskLocation
		percentFromLeft=(float(left-deskLeft)/deskWidth)*100
		percentFromTop=(float(top-deskTop)/deskHeight)*100
		percentWidth=(float(width)/deskWidth)*100
		percentHeight=(float(height)/deskHeight)*100
		ui.message(_("Object edges positioned %.1f per cent from left edge of screen, %.1f per cent from top edge of screen, width is %.1f per cent of screen, height is %.1f per cent of screen")%(percentFromLeft,percentFromTop,percentWidth,percentHeight))
コード例 #52
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)
コード例 #53
0
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
ファイル: excel.py プロジェクト: JamaicanUser/nvda
	def moveTo(self):
		try:
			self.excelItemObject.Activate()

			# After activate(), though the chart object is selected, 

			# pressing arrow keys moves the object, rather than 

			# let use go inside for sub-objects. Somehow 
		# calling an COM function on a different object fixes that !

			log.debugWarning( self.excelItemCollection.Count )

		except(COMError):

			pass
		focus=api.getDesktopObject().objectWithFocus()
		if not focus or not isinstance(focus,ExcelBase):
			return
		# Charts are not yet automatically detected with objectFromFocus, so therefore use selection
		sel=focus._getSelection()
		if not sel:
			return
		eventHandler.queueEvent("gainFocus",sel)
コード例 #55
0
ファイル: winword.py プロジェクト: eklipse2009/nvda
	def focusOnActiveDocument(self, officeChartObject):
		rangeStart=officeChartObject.Parent.Range.Start
		self.WinwordApplicationObject.ActiveDocument.Range(rangeStart, rangeStart).Select()
		import api
		eventHandler.executeEvent("gainFocus", api.getDesktopObject().objectWithFocus())
コード例 #56
0
ファイル: ia2TextMozilla.py プロジェクト: dnz3d4c/nvda
	def __init__(self, obj, position):
		super(MozillaCompoundTextInfo, self).__init__(obj, position)
		if isinstance(position, NVDAObject):
			# FIXME
			position = textInfos.POSITION_CARET
		if isinstance(position, self.__class__):
			self._start = position._start.copy()
			self._startObj = position._startObj
			if position._end is position._start:
				self._end = self._start
			else:
				self._end = position._end.copy()
			self._endObj = position._endObj
		elif position in (textInfos.POSITION_FIRST, textInfos.POSITION_LAST):
			self._start, self._startObj = self._findContentDescendant(obj, position)
			self._end = self._start
			self._endObj = self._startObj
		elif position == textInfos.POSITION_ALL:
			self._start, self._startObj = self._findContentDescendant(obj, textInfos.POSITION_FIRST)
			self._start.expand(textInfos.UNIT_STORY)
			self._end, self._endObj = self._findContentDescendant(obj, textInfos.POSITION_LAST)
			self._end.expand(textInfos.UNIT_STORY)
		elif position == textInfos.POSITION_CARET:
			try:
				caretTi, caretObj = self._findContentDescendant(obj, textInfos.POSITION_CARET)
			except LookupError:
				raise RuntimeError("No caret")
			if caretObj is not obj and caretObj.IA2Attributes.get("display") == "inline" and caretTi.compareEndPoints(self._makeRawTextInfo(caretObj, textInfos.POSITION_ALL), "startToEnd") == 0:
				# The caret is at the end of an inline object.
				# This will report "blank", but we want to report the character just after the caret.
				try:
					caretTi, caretObj = self._findNextContent(caretTi)
				except LookupError:
					pass
			self._start = self._end = caretTi
			self._startObj = self._endObj = caretObj
		elif position == textInfos.POSITION_SELECTION:
			# The caret is usually within the selection,
			# so start from the caret for better performance/tolerance of server brokenness.
			tempTi, tempObj = self._findContentDescendant(obj, textInfos.POSITION_CARET)
			try:
				tempTi = self._makeRawTextInfo(tempObj, position)
			except RuntimeError:
				# The caret is just before this object.
				# There is never a selection in this case.
				pass
			else:
				if tempTi.isCollapsed:
					# No selection, but perhaps the caret is at the start of the next/previous object.
					# This happens when you, for example, press shift+rightArrow at the end of a block.
					# Try from the root.
					rootTi = self._makeRawTextInfo(obj, position)
					if not rootTi.isCollapsed:
						# There is definitely a selection.
						tempTi, tempObj = rootTi, obj
			if tempTi.isCollapsed:
				# No selection, so use the caret.
				self._start = self._end = tempTi
				self._startObj = self._endObj = tempObj
			else:
				self._start, self._startObj, self._end, self._endObj = self._findUnitEndpoints(tempTi, position)
		elif isinstance(position, textInfos.Point):
			startObj = api.getDesktopObject().objectFromPoint(position.x, position.y)
			while startObj and startObj.role == controlTypes.ROLE_STATICTEXT:
				# Skip text leaf nodes.
				startObj = startObj.parent
			if not startObj:
				raise LookupError
			self._startObj = startObj
			self._start = self._makeRawTextInfo(startObj, position)
			self._end = self._start
			self._endObj = self._startObj
		else:
			raise NotImplementedError
コード例 #57
0
ファイル: explorer.py プロジェクト: BabbageCom/nvda
	def _get_container(self):
		if winUser.getAsyncKeyState(winUser.VK_MENU)&32768:
			return api.getDesktopObject()
		else:
			return super(MultitaskingViewFrameListItem,self).container
コード例 #58
0
ファイル: excel.py プロジェクト: JamaicanUser/nvda
	def moveTo(self):
		self.sheetObject.Activate()
		eventHandler.queueEvent("gainFocus",api.getDesktopObject().objectWithFocus())
コード例 #59
0
ファイル: adobeAcrobat.py プロジェクト: Alain-Ambazac/nvda
	def _get_parent(self):
		#hack: This code should be taken out once the crash is fixed in Adobe Reader X.
		#If going parent on a root text node after saying ok to the accessibility options (untagged) and before the processing document dialog appears, Reader X will crash.
		return api.getDesktopObject()
コード例 #60
0
ファイル: IAccessibleHandler.py プロジェクト: BabbageCom/nvda
def _correctFocus():
	eventHandler.queueEvent("gainFocus",api.getDesktopObject().objectWithFocus())