示例#1
0
    def shouldReport(self):
        # Avoid reporting systray tool-tips if their text equals the focused systray icon name (#6656)

        # Don't bother checking if reporting of tool-tips is disabled
        if not config.conf["presentation"]["reportTooltips"]:
            return False

        focus = api.getFocusObject()

        # Report if either
        #  - the mouse has just moved
        #  - the focus is not in the systray
        #  - we do not know (yet) where the systray is located
        if (mouseHandler.lastMouseEventTime >= time.time() - 0.2
                or not isinstance(focus, NotificationArea)
                or NotificationArea.lastKnownLocation is None):
            return True

        # Report if the mouse is indeed located in the systray
        systrayLeft, systrayTop, systrayWidth, systrayHeight = NotificationArea.lastKnownLocation
        mouseLeft, mouseTop = winUser.getCursorPos()
        if (systrayLeft <= mouseLeft <= systrayLeft + systrayWidth
                and systrayTop <= mouseTop <= systrayTop + systrayHeight):
            return True

        # Report is the next are different
        if focus.name != self.name:
            return True

        # Do not report otherwise
        return False
示例#2
0
 def _activateNVDAObject(self, obj):
     while obj and obj != self.rootNVDAObject:
         try:
             obj.doAction()
             break
         except:
             log.debugWarning("doAction failed")
         if controlTypes.STATE_OFFSCREEN in obj.states or controlTypes.STATE_INVISIBLE in obj.states:
             obj = obj.parent
             continue
         try:
             l, t, w, h = obj.location
         except TypeError:
             log.debugWarning("No location for object")
             obj = obj.parent
             continue
         if not w or not h:
             obj = obj.parent
             continue
         log.debugWarning("Clicking with mouse")
         x = l + w / 2
         y = t + h / 2
         oldX, oldY = winUser.getCursorPos()
         winUser.setCursorPos(x, y)
         winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0, None, None)
         winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None)
         winUser.setCursorPos(oldX, oldY)
         break
示例#3
0
	def _activateNVDAObject(self, obj):
		while obj and obj != self.rootNVDAObject:
			try:
				obj.doAction()
				break
			except:
				log.debugWarning("doAction failed")
			if controlTypes.STATE_OFFSCREEN in obj.states or controlTypes.STATE_INVISIBLE in obj.states:
				obj = obj.parent
				continue
			try:
				l, t, w, h = obj.location
			except TypeError:
				log.debugWarning("No location for object")
				obj = obj.parent
				continue
			if not w or not h:
				obj = obj.parent
				continue
			log.debugWarning("Clicking with mouse")
			x = l + w / 2
			y = t + h / 2
			oldX, oldY = winUser.getCursorPos()
			winUser.setCursorPos(x, y)
			mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0)
			mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_LEFTUP, 0, 0)
			winUser.setCursorPos(oldX, oldY)
			break
示例#4
0
    def script_saveMousePosition(self, gesture):
        x, y = winUser.getCursorPos()
        # Stringify coordinates early.
        x, y = str(x), str(y)
        # Translators: edit field label for new mouse position.
        d = EnterPositionName(
            gui.mainFrame,
            _("Enter the name for the current mouse position (x: {x}, Y: {y})".
              format(x=x, y=y)),
            # Translators: title for save mouse position dialog.
            _("Save mouse position"))

        def callback(result):
            if result == wx.ID_OK:
                name = d.GetValue().rstrip()
                if name == "": return
                appName = self.getMouse().appModule.appName
                # If the files path does not exist, create it now.
                if not os.path.exists(GCMousePositions):
                    os.mkdir(GCMousePositions)
                position = ConfigObj(os.path.join(GCMousePositions,
                                                  appName + ".gc"),
                                     encoding="UTF-8")
                position[name] = ",".join([x, y])
                position.write()
                # Translators: presented when position (tag) has been saved.
                ui.message(_("Position saved in %s.") % position.filename)

        gui.runScriptModalDialog(d, callback)
示例#5
0
    def event_gainFocus(self):
        NotificationArea.lastKnownLocation = self.location
        if mouseHandler.lastMouseEventTime < time.time() - 0.2:
            # This focus change was not caused by a mouse event.
            # If the mouse is on another systray 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.
            if self.location:
                systrayLeft, systrayTop, systrayWidth, systrayHeight = self.location
                mouseLeft, mouseTop = winUser.getCursorPos()
                if (systrayLeft <= mouseLeft <= systrayLeft + systrayWidth and
                        systrayTop <= mouseTop <= systrayTop + systrayHeight):
                    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()
示例#6
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))
示例#7
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()
示例#8
0
def reportMousePosition(x=None, y=None):
    # The coordinates are keywords so specific position can be announced if needed.
    cursorPos = winUser.getCursorPos()
    if x is None:
        x = cursorPos[0]
    if y is None:
        y = cursorPos[1]
    ui.message("{0}, {1}".format(x, y))
示例#9
0
文件: b2.py 项目: lukaszgo1/Becky
 def script_deleteItem(self, gesture):
     if self.IAccessibleChildID == 1:
         return
     (left, top, width, height) = self.location
     oldMouseCoords = winUser.getCursorPos()
     x = left + (width // 2)
     y = top + (height // 2)
     winUser.setCursorPos(x, y)
     mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_RIGHTDOWN, 0, 0)
     mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_RIGHTUP, 0, 0)
     winUser.setCursorPos(*oldMouseCoords)
示例#10
0
文件: b2.py 项目: lukaszgo1/Becky
 def _activateURLAtPos(pos):
     # If user configures Becky! to open links with a single click they're underlined.
     shouldClickTwice = DanaEdit._TIMatchesCondition(
         pos, "underline", False)
     oldMouseCoords = winUser.getCursorPos()
     winUser.setCursorPos(pos.pointAtStart.x, pos.pointAtStart.y)
     mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0)
     mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_LEFTUP, 0, 0)
     if shouldClickTwice:
         mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0)
         mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_LEFTUP, 0, 0)
     winUser.setCursorPos(*oldMouseCoords)
示例#11
0
	def _setCaretOffset(self,offset):
		rects=self._textAndRects[1]
		if offset>=len(rects):
			raise RuntimeError("offset %d out of range")
		left,top,right,bottom=rects[offset]
		x=left #+(right-left)/2
		y=top+(bottom-top)/2
		oldX,oldY=winUser.getCursorPos()
		winUser.setCursorPos(x,y)
		winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN,0,0,None,None)
		winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP,0,0,None,None)
		winUser.setCursorPos(oldX,oldY)
示例#12
0
	def _setCaretOffset(self,offset):
		rects=self._storyFieldsAndRects[1]
		if offset>=len(rects):
			raise RuntimeError("offset %d out of range")
		rect = rects[offset]
		x = rect.left
		y= rect.center.y
		x,y=windowUtils.logicalToPhysicalPoint(self.obj.windowHandle,x,y)
		oldX,oldY=winUser.getCursorPos()
		winUser.setCursorPos(x,y)
		mouseHandler.doPrimaryClick()
		winUser.setCursorPos(oldX,oldY)
示例#13
0
 def doAction(self, index=None):
     if not index:
         l = self.location
         if l:
             x = l[0]
             y = l[1]
             oldX, oldY = winUser.getCursorPos()
             winUser.setCursorPos(x, y)
             mouseHandler.doPrimaryClick(releaseDelay=0.2)
             winUser.setCursorPos(oldX, oldY)
             return
     raise NotImplementedError
示例#14
0
 def _setCaretOffset(self, offset):
     rects = self._textAndRects[1]
     if offset >= len(rects):
         raise RuntimeError("offset %d out of range")
     left, top, right, bottom, baseline = rects[offset]
     x = left  #+(right-left)/2
     y = top + (bottom - top) / 2
     oldX, oldY = winUser.getCursorPos()
     winUser.setCursorPos(x, y)
     winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0, None, None)
     winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None)
     winUser.setCursorPos(oldX, oldY)
示例#15
0
	def _setCaretOffset(self,offset):
		rects=self._storyFieldsAndRects[1]
		if offset>=len(rects):
			raise RuntimeError("offset %d out of range")
		rect = rects[offset]
		x = rect.left
		y= rect.center.y
		x,y=windowUtils.logicalToPhysicalPoint(self.obj.windowHandle,x,y)
		oldX,oldY=winUser.getCursorPos()
		winUser.setCursorPos(x,y)
		mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_LEFTDOWN,0,0)
		mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_LEFTUP,0,0)
		winUser.setCursorPos(oldX,oldY)
示例#16
0
	def _setCaretOffset(self,offset):
		rects=self._storyFieldsAndRects[1]
		if offset>=len(rects):
			raise RuntimeError("offset %d out of range")
		left,top,right,bottom=rects[offset]
		x=left #+(right-left)/2
		y=top+(bottom-top)/2
		x,y=windowUtils.logicalToPhysicalPoint(self.obj.windowHandle,x,y)
		oldX,oldY=winUser.getCursorPos()
		winUser.setCursorPos(x,y)
		mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_LEFTDOWN,0,0)
		mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_LEFTUP,0,0)
		winUser.setCursorPos(oldX,oldY)
示例#17
0
	def _setCaretOffset(self,offset):
		rects=self._storyFieldsAndRects[1]
		if offset>=len(rects):
			raise RuntimeError("offset %d out of range")
		left,top,right,bottom=rects[offset]
		x=left #+(right-left)/2
		y=top+(bottom-top)/2
		x,y=windowUtils.logicalToPhysicalPoint(self.obj.windowHandle,x,y)
		oldX,oldY=winUser.getCursorPos()
		winUser.setCursorPos(x,y)
		winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN,0,0,None,None)
		winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP,0,0,None,None)
		winUser.setCursorPos(oldX,oldY)
示例#18
0
	def activate(self):
		"""Activate this position.
		For example, this might activate the object at this position or click the point at this position.
		@raise NotImplementedError: If not supported.
		"""
		if not self.obj.isInForeground:
			raise NotImplementedError
		import winUser
		p=self.pointAtStart
		oldX,oldY=winUser.getCursorPos()
		winUser.setCursorPos(p.x,p.y)
		winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN,0,0,None,None)
		winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP,0,0,None,None)
		winUser.setCursorPos(oldX,oldY)
示例#19
0
	def activate(self):
		"""Activate this position.
		For example, this might activate the object at this position or click the point at this position.
		@raise NotImplementedError: If not supported.
		"""
		if not self.obj.isInForeground:
			raise NotImplementedError
		import mouseHandler
		import winUser
		p=self.pointAtStart
		oldX,oldY=winUser.getCursorPos()
		winUser.setCursorPos(p.x,p.y)
		mouseHandler.doPrimaryClick()
		winUser.setCursorPos(oldX,oldY)
示例#20
0
    def activate(self):
        """Activate this position.
		For example, this might activate the object at this position or click the point at this position.
		@raise NotImplementedError: If not supported.
		"""
        if not self.obj.isInForeground:
            raise NotImplementedError
        import winUser
        p = self.pointAtStart
        oldX, oldY = winUser.getCursorPos()
        winUser.setCursorPos(p.x, p.y)
        winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0, None, None)
        winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None)
        winUser.setCursorPos(oldX, oldY)
示例#21
0
	def doAction(self,index=None):
		if not index:
			l=self.location
			if l:
				x=l[0]
				y=l[1]
				oldX,oldY=winUser.getCursorPos()
				winUser.setCursorPos(x,y)
				mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_LEFTDOWN,0,0)
				time.sleep(0.2)
				mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_LEFTUP,0,0)
				winUser.setCursorPos(oldX,oldY)
				return
		raise NotImplementedError
示例#22
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)
示例#23
0
	def script_doAction(self, gesture):
		# code written by Javi Dominguez and adapted to this add-on
		printDebug("script_doAction")
		obj = api.getNavigatorObject()
		mainWindow = self.appModule.mainWindow
		anchoredPlaylist = mainWindow.mainPanel.anchoredPlaylist
		oldAnchoredPlaylistState = anchoredPlaylist.isVisible()
		controlPanel = mainWindow.mainPanel.controlPanel
		if obj not in controlPanel.controls[1:]:
			gesture.send()
			return
		description = obj.description
		if obj.role not in [controlTypes.ROLE_BUTTON, controlTypes.ROLE_GRAPHIC]:
			obj.doAction()
			msg = []
			for state in obj.states:
				msg.append(controlTypes.stateLabels[state])
			desc = api.getMouseObject().description
			if obj.role == controlTypes.ROLE_CHECKBOX and\
				controlTypes.STATE_CHECKED not in obj.states:
				msg.append(_("unchecked"))
				if desc:
					msg.append(api.getMouseObject().description)
			elif desc and description == desc:
				msg.append(desc)
			if len(msg):
				text = ", ".join(msg)
				ui.message(text)
		else:
			api.moveMouseToNVDAObject(obj)
			x, y = winUser.getCursorPos()
			o = api.getDesktopObject().objectFromPoint(x, y) 
			if o.description == obj.description:
				controlPanel.clickButton(obj)
				api.processPendingEvents()
				api.moveMouseToNVDAObject(obj)
				o = api.getDesktopObject().objectFromPoint(x, y)
				if description != o.description:
					ui.message(api.getMouseObject().description)
			else:
				pass
		newAnchoredPlaylistState = anchoredPlaylist.isVisible()
		if not oldAnchoredPlaylistState and newAnchoredPlaylistState:
			obj = anchoredPlaylist.NVDAObject
			mouseClick(obj)
			return
		# put focus on new dialog if there is one (like adjustments and effects)
		self.focusDialog()
示例#24
0
 def doAction(self, index=None):
     if not index:
         l = self.location
         if l:
             x = l[0]
             y = l[1]
             oldX, oldY = winUser.getCursorPos()
             winUser.setCursorPos(x, y)
             mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_LEFTDOWN, 0,
                                            0)
             time.sleep(0.2)
             mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_LEFTUP, 0,
                                            0)
             winUser.setCursorPos(oldX, oldY)
             return
     raise NotImplementedError
示例#25
0
文件: webKit.py 项目: zstanecic/nvda
	def _activateNVDAObject(self, obj):
		try:
			obj.doAction()
			return
		except:
			pass

		log.debugWarning("could not programmatically activate field, trying mouse")
		l=obj.location
		if not l:
			log.debugWarning("no location for field")
			return
		oldX,oldY=winUser.getCursorPos()
		winUser.setCursorPos(*l.center)
		mouseHandler.doPrimaryClick()
		winUser.setCursorPos(oldX,oldY)
示例#26
0
	def _activateNVDAObject(self, obj):
		try:
			obj.doAction()
		except:
			log.debugWarning("could not programmatically activate field, trying mouse")
			l=obj.location
			if l:
				x=(l[0]+l[2]/2)
				y=l[1]+(l[3]/2) 
				oldX,oldY=winUser.getCursorPos()
				winUser.setCursorPos(x,y)
				winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN,0,0,None,None)
				winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP,0,0,None,None)
				winUser.setCursorPos(oldX,oldY)
			else:
				log.debugWarning("no location for field")
示例#27
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)
示例#28
0
文件: vlc.py 项目: javidominguez/VLC
 def selectItem(self, item):
     if item and item.role == controlTypes.Role.LISTITEM:
         item.scrollIntoView()
         api.setNavigatorObject(item)
         api.moveMouseToNVDAObject(item)
         x, y = winUser.getCursorPos()
         if api.getDesktopObject().objectFromPoint(x, y) == item:
             winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0, None,
                                 None)
             winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None,
                                 None)
             item.setFocus()
             api.setFocusObject(item)
             if item.name: ui.message(item.name)
         else:
             tones.beep(200, 20)
示例#29
0
	def _activateNVDAObject(self, obj):
		try:
			obj.doAction()
			return
		except:
			pass

		log.debugWarning("could not programmatically activate field, trying mouse")
		l=obj.location
		if not l:
			log.debugWarning("no location for field")
			return
		oldX,oldY=winUser.getCursorPos()
		winUser.setCursorPos(*l.center)
		mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_LEFTDOWN,0,0)
		mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_LEFTUP,0,0)
		winUser.setCursorPos(oldX,oldY)
示例#30
0
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)
 def _setCaretOffset(self, offset):
     rects = self._storyFieldsAndRects[1]
     if offset >= len(rects):
         raise RuntimeError("offset %d out of range")
     rect = rects[offset]
     # Place the cursor at the left coordinate of the character, vertically centered.
     point = Point(rect.left, rect.center.y)
     try:
         point = point.toPhysical(self.obj.windowHandle)
     except RuntimeError:
         raise RuntimeError(
             "Conversion to physical coordinates failed when setting caret offset"
         )
     oldX, oldY = winUser.getCursorPos()
     winUser.setCursorPos(*point)
     mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0)
     mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_LEFTUP, 0, 0)
     winUser.setCursorPos(oldX, oldY)
	def selectItem(self, item):
		if item:
			item.scrollIntoView()
			api.setNavigatorObject(item)
			api.moveMouseToNVDAObject(item)
			x, y = winUser.getCursorPos()
			if api.getDesktopObject().objectFromPoint(x, y) == item:
				winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0, None, None)
				winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None)
				time.sleep(0.1)
				eventHandler.queueEvent("gainFocus", item)
				return
				item.setFocus()
				api.setFocusObject(item)
				if item.name:
					ui.message(item.name)
			else:
				pass
示例#33
0
	def _activateNVDAObject(self, obj):
		try:
			obj.doAction()
		except:
			log.debugWarning("could not programmatically activate field, trying mouse")
			while obj and controlTypes.STATE_OFFSCREEN in obj.states and obj!=self.rootNVDAObject:
				obj=obj.parent
			l=obj.location
			if l:
				x=(l[0]+l[2]/2)
				y=l[1]+(l[3]/2) 
				oldX,oldY=winUser.getCursorPos()
				winUser.setCursorPos(x,y)
				winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN,0,0,None,None)
				winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP,0,0,None,None)
				winUser.setCursorPos(oldX,oldY)
			else:
				log.debugWarning("no location for field")
示例#34
0
	def _activateNVDAObject(self, obj):
		try:
			obj.doAction()
			return
		except:
			pass

		log.debugWarning("could not programmatically activate field, trying mouse")
		l=obj.location
		if not l:
			log.debugWarning("no location for field")
			return
		x=(l[0]+l[2]/2)
		y=l[1]+(l[3]/2) 
		oldX,oldY=winUser.getCursorPos()
		winUser.setCursorPos(x,y)
		mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_LEFTDOWN,0,0)
		mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_LEFTUP,0,0)
		winUser.setCursorPos(oldX,oldY)
示例#35
0
	def _activateNVDAObject(self, obj):
		try:
			obj.doAction()
			return
		except:
			pass

		log.debugWarning("could not programmatically activate field, trying mouse")
		l=obj.location
		if not l:
			log.debugWarning("no location for field")
			return
		x=(l[0]+l[2]/2)
		y=l[1]+(l[3]/2) 
		oldX,oldY=winUser.getCursorPos()
		winUser.setCursorPos(x,y)
		winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN,0,0,None,None)
		winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP,0,0,None,None)
		winUser.setCursorPos(oldX,oldY)
示例#36
0
 def script_clickPinConsoleButton(self, gesture):
     self.get_pin_console_button()
     if self.pinConsoleButton != None:
         try:
             oldX, oldY = winUser.getCursorPos()
             winUser.setCursorPos(self.pinConsoleButton.location.left,
                                  self.pinConsoleButton.location.top)
             #perform Mouse Left-Click
             mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_LEFTDOWN, 0,
                                            0)
             mouseHandler.executeMouseEvent(winUser.MOUSEEVENTF_LEFTUP, 0,
                                            0)
             winUser.setCursorPos(oldX, oldY)
             if controlTypes.State.CHECKED in self.pinConsoleButton.states:
                 ui.message(_("Pin Console") + " " + _("not checked"))
             else:
                 ui.message(_("Pin Console") + " " + _("checked"))
         except:
             pass
示例#37
0
文件: vlc.py 项目: javidominguez/VLC
 def script_doAction(self, gesture):
     obj = api.getNavigatorObject()
     if obj not in self.playbackControls:
         gesture.send()
         return
     try:
         obj.doAction()
         for state in obj.states:
             ui.message(controlTypes.stateLabels[state])
         if obj.role == controlTypes.Role.CHECKBOX and controlTypes.State.CHECKED not in obj.states:
             ui.message(_("unchecked"))
     except:
         api.moveMouseToNVDAObject(obj)
         x, y = winUser.getCursorPos()
         if api.getDesktopObject().objectFromPoint(x, y) == obj:
             self.mouseClick()
         else:
             tones.beep(200, 50)
     self.focusDialog()
示例#38
0
 def script_menu(self, gesture):
     obj = api.getNavigatorObject()
     if obj.parent == self and controlTypes.STATE_INVISIBLE not in obj.states:
         scriptHandler.executeScript(
             globalCommands.commands.script_moveMouseToNavigatorObject,
             None)
         pauseSpeech(True)
         x, y = winUser.getCursorPos()
         if x >= obj.location[0]:
             winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTDOWN, 0, 0, None,
                                 None)
             winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTUP, 0, 0, None,
                                 None)
         else:
             # TRANSLATORS: Message when it can't click in a item of the toolbar
             ui.message(
                 _("Can't click in %s, try to maximize the window") %
                 (obj.name
                  if obj.name else controlTypes.roleLabels[obj.role]))
     else:
         beep(200, 80)
示例#39
0
 def _activateNVDAObject(self, obj):
     while obj and obj != self.rootNVDAObject:
         try:
             obj.doAction()
             break
         except:
             log.debugWarning("doAction failed")
         if obj.hasIrrelevantLocation:
             # This check covers invisible, off screen and a None location
             log.debugWarning("No relevant location for object")
             obj = obj.parent
             continue
         location = obj.location
         if not location.width or not location.height:
             obj = obj.parent
             continue
         log.debugWarning("Clicking with mouse")
         oldX, oldY = winUser.getCursorPos()
         winUser.setCursorPos(*location.center)
         mouseHandler.doPrimaryClick()
         winUser.setCursorPos(oldX, oldY)
         break
示例#40
0
 def getMouse(self):
     return api.getDesktopObject().objectFromPoint(*winUser.getCursorPos())