Ejemplo n.º 1
0
    def dragVertical(self, x, y, step):
        self.moveCursor(x, y)

        winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0, None, None)
        self.moveCursor(x, y - step)
        time.sleep(0.05)
        winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None)
Ejemplo n.º 2
0
def mouseEvents(location, *events):
	x,y = int (location[0]+location[2]/2), int (location[1]+location[3]/2)
	#move the cursor
	winUser.setCursorPos (x,y)
	#simulation of pressing mouse button
	for event in events:
		winUser.mouse_event(event, 0, 0, None, None)
Ejemplo n.º 3
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
Ejemplo n.º 4
0
 def addressField(self, index, rightClick):
     if self.isDocument():
         fields = []
         for item in filter(lambda o: o.role == controlTypes.ROLE_UNKNOWN,
                            self.getPropertyPage().children):
             try:
                 fields.append(item.children[0].children[0])
             except IndexError:
                 pass
         if index >= len(fields):
             return
         try:
             ui.message(",".join(
                 [o.name for o in fields[index].parent.children]))
         except (IndexError, AttributeError):
             #TRANSLATORS: cannot find sender address
             ui.message(_("Not found"))
         if rightClick:
             api.moveMouseToNVDAObject(
                 fields[index].getChild(0).getChild(1))
             api.setMouseObject(fields[index].getChild(0).getChild(1))
             winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTDOWN, 0, 0, None,
                                 None)
             winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTUP, 0, 0, None,
                                 None)
             speech.pauseSpeech(True)
     else:
         #TRANSLATORS: message spoken if you try to read the sender address out of a message window
         ui.message(_("you are not in a message window"))
Ejemplo n.º 5
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
Ejemplo n.º 6
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
Ejemplo n.º 7
0
	def script_toggleRightMouseButton(self,gesture):
		if winUser.getKeyState(winUser.VK_RBUTTON)&32768:
			ui.message(_("right mouse button unlock"))
			winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTUP,0,0,None,None)
		else:
			ui.message(_("right mouse button lock"))
			winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTDOWN,0,0,None,None)
 def clickLeftMouseButton(self, nb):
     self.Close()
     (x, y) = self.getPositionXY()
     winUser.setCursorPos(x, y)
     for i in range(nb):
         winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0, None, None)
         winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None)
 def onRightMouseButton(self, event):
     (x, y) = self.getPositionXY()
     self.Close()
     winUser.setCursorPos(x, y)
     winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTDOWN, 0, 0, None, None)
     time.sleep(0.01)
     winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTUP, 0, 0, None, None)
Ejemplo n.º 10
0
    def leftClick(self):
        """
            Déclanchement d'un click gauche
        """

        winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0, None, None)
        winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None)
Ejemplo n.º 11
0
 def onRightClick(self, event):
     index = self.list.GetSelection()
     headerObj = self.headerList[index]
     self.Destroy()
     api.setNavigatorObject(headerObj)
     commands.script_moveMouseToNavigatorObject(None)
     winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTDOWN, 0, 0, None, None)
     winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTUP, 0, 0, None, None)
     ui.message(_("%s header clicked") % headerObj.name)
Ejemplo n.º 12
0
 def script_headerOptions(self, gesture):
     if self.parent.simpleParent.role == controlTypes.ROLE_DIALOG: return
     obj = self.parent.getChild(1)
     while obj.name != self.columnHeaderText and obj.role == controlTypes.ROLE_TABLECOLUMNHEADER:
         obj = obj.next
     api.setNavigatorObject(obj)
     speakObject(obj)
     winUser.setCursorPos(self.location[0] + 2, obj.location[1] + 2)
     winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTDOWN, 0, 0, None, None)
     winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTUP, 0, 0, None, None)
 def click(self):
     speech.cancelSpeech()
     left, top, width, height = self.location
     x = left + (width / 2)
     y = top + (height / 2)
     #click the middle of the screen after moving to this location.
     winUser.setCursorPos(x, y)
     winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0, None, None)
     winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None)
     speech.cancelSpeech()
Ejemplo n.º 14
0
 def script_headerOptions(self, gesture):
     if self.parent.simpleParent.role == controlTypes.ROLE_DIALOG: return
     obj = self.table.simpleFirstChild
     while obj.name != self.columnHeaderText and obj.role == controlTypes.ROLE_HEADER:
         obj = obj.next
     api.setNavigatorObject(obj)
     winUser.setCursorPos(self.location[0] + 2, obj.location[1] + 2)
     winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTDOWN, 0, 0, None, None)
     winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTUP, 0, 0, None, None)
     KeyboardInputGesture.fromName("downArrow").send()
Ejemplo n.º 15
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)
     winUser.setCursorPos(x, y)
     winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0, None, None)
     winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None)
Ejemplo n.º 16
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)
Ejemplo n.º 17
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)
Ejemplo n.º 18
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)
Ejemplo n.º 19
0
 def script_pressButton(self, gesture):
     if self.pointedObj:
         if controlTypes.STATE_PRESSED in self.pointedObj.states:
             #TRANSLATORS: a button has been unchecked
             ui.message(_("uncheck"))
         else:
             #TRANSLATORS: a button has been checked
             ui.message(_("check"))
         ui.message(self.pointedObj.name)
         api.moveMouseToNVDAObject(self.pointedObj)
         api.setMouseObject(self.pointedObj)
         winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0, None, None)
         winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None)
Ejemplo n.º 20
0
 def script_pressItem(self, gesture):
     nav = api.getNavigatorObject()
     api.moveMouseToNVDAObject(nav)
     winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0, None, None)
     winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None)
     winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0, None, None)
     winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None)
Ejemplo n.º 21
0
	def script_list(self, gesture):
		try:
			obj = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
				windowUtils.findDescendantWindow(
					api.getForegroundObject().windowHandle, visible=True, className="SysListView32"
				), winUser.OBJID_CLIENT, 0
			)
		except LookupError:
			return
		if obj != api.getFocusObject():
			api.moveMouseToNVDAObject(obj)
			api.setMouseObject(obj)
			winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0, None, None)
			winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None)
Ejemplo n.º 22
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)
Ejemplo n.º 23
0
	def script_showSelectionOptions(self, gesture):
		fakeSel = self.selection
		if fakeSel.isCollapsed:
			# Double click to access the toolbar; e.g. for annotations.
			try:
				p = fakeSel.pointAtStart
			except NotImplementedError:
				log.debugWarning("Couldn't get point to click")
				return
			log.debug("Double clicking")
			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.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0, None, None)
			winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None)
			return

		# The user makes a selection using browse mode virtual selection.
		# Update the selection in Kindle.
		# This will cause the options to appear.
		fakeSel.innerTextInfo.updateSelection()
		# The selection might have been adjusted to meet word boundaries,
		# so retrieve and report the selection from Kindle.
		# we can't just use self.makeTextInfo, as that will use our fake selection.
		realSel = self.rootNVDAObject.makeTextInfo(textInfos.POSITION_SELECTION)
		# Translators: Announces selected text. %s is replaced with the text.
		speech.speakSelectionMessage(_("selected %s"), realSel.text)
		# Remove our virtual selection and move the caret to the active end.
		fakeSel.innerTextInfo = realSel
		fakeSel.collapse(end=not self._lastSelectionMovedStart)
		self.selection = fakeSel
Ejemplo n.º 24
0
	def script_showSelectionOptions(self, gesture):
		fakeSel = self.selection
		if fakeSel.isCollapsed:
			# Double click to access the toolbar; e.g. for annotations.
			try:
				p = fakeSel.pointAtStart
			except NotImplementedError:
				log.debugWarning("Couldn't get point to click")
				return
			log.debug("Double clicking")
			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.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0, None, None)
			winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None)
			return

		# The user makes a selection using browse mode virtual selection.
		# Update the selection in Kindle.
		# This will cause the options to appear.
		fakeSel.innerTextInfo.updateSelection()
		# The selection might have been adjusted to meet word boundaries,
		# so retrieve and report the selection from Kindle.
		# we can't just use self.makeTextInfo, as that will use our fake selection.
		realSel = self.rootNVDAObject.makeTextInfo(textInfos.POSITION_SELECTION)
		# Translators: Announces selected text. %s is replaced with the text.
		speech.speakSelectionMessage(_("selected %s"), realSel.text)
		# Remove our virtual selection and move the caret to the active end.
		fakeSel.innerTextInfo = realSel
		fakeSel.collapse(end=not self._lastSelectionMovedStart)
		self.selection = fakeSel
Ejemplo n.º 25
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)
Ejemplo n.º 26
0
	def script_enter(self, gesture):
		api.moveMouseToNVDAObject(self)
		api.setMouseObject(self)
		winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN,0,0,None,None)
		winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP,0,0,None,None)
		winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN,0,0,None,None)
		winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP,0,0,None,None)
Ejemplo n.º 27
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)
				winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN,0,0,None,None)
				time.sleep(0.2)
				winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP,0,0,None,None)
				winUser.setCursorPos(oldX,oldY)
				return
		raise NotImplementedError
Ejemplo n.º 28
0
    def leftDrag(self, timeout=0.3, mouse_up=True):
        """ Drag with left button from x,y to r,b coordinates.
		Dangerous! When mouse_up is false, should be paired with leftUp !!!
		Args:
			timeout (float): time (in seconds) to wait before moving from initial to final position
			mouse_up (bool): generate mouse_up event after dragging (!!! Dangerous !!!) 
		"""
        self.moveTo()
        winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0, None, None)
        watchdog.asleep()  # do not let watchdog interrupt us
        time.sleep(timeout)
        watchdog.alive()
        libsibiac.MouseMove(self.windowHandle, c_int(self.r), c_int(self.b))
        if mouse_up:
            winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None)
Ejemplo n.º 29
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)
             winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0, None,
                                 None)
             time.sleep(0.2)
             winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None,
                                 None)
             winUser.setCursorPos(oldX, oldY)
             return
     raise NotImplementedError
Ejemplo n.º 30
0
 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)
Ejemplo n.º 31
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")
Ejemplo n.º 32
0
	def mouseClick(self, obj, button="left"):
			api.moveMouseToNVDAObject(obj)
			api.setMouseObject(obj)
			if button == "left":
				winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN,0,0,None,None)
				winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP,0,0,None,None)
			if button == "right":
				winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTDOWN,0,0,None,None)
				winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTUP,0,0,None,None)
Ejemplo n.º 33
0
	def script_clickButtonCancel (self,gesture):
		# Translators: the title of the dropbox preferences dialog, it is important to have the same capitalization/spelling as in the dropbox gui. If Dropbox hasn't been translated to your language yet, leave this blank or write the original text.
		if api.getFocusObject().windowText == u'DropboxTrayIcon' or api.getFocusObject().windowClassName == u'#32768' or api.getForegroundObject().name != _("Dropbox Preferences"):
			gesture.send()
			return
		cancelButton=api.getForegroundObject().simpleLastChild
		# Translators: the name of the dropbox preferences cancel button, it is important to have the same capitalization/spelling as in the dropbox gui. If Dropbox hasn't been translated to your language yet, leave this blank or write the original text.
		if cancelButton.name != _('Cancel'):
			cancelButton=cancelButton.simplePrevious if cancelButton.simplePrevious.name == _('Cancel') else None
		if cancelButton == None:
			ui.message(_("Cancel button not found"))
			gesture.send()
		else:
			(x,y,l,h) = cancelButton.IAccessibleObject.accLocation (0)
			winUser.setCursorPos (x,y)
			winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN,0,0,None,None)
			winUser.mouse_event (winUser.MOUSEEVENTF_LEFTUP,0,0,None,None)
Ejemplo n.º 34
0
	def script_searchList(self, gesture):
		where = self.getWhere()
		if not hasattr(where, "IAccessibleChildID") or where.IAccessibleChildID != 6:
			return
		try:
			obj = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
				windowUtils.findDescendantWindow(
					api.getForegroundObject().windowHandle, controlID=2833
				), winUser.OBJID_CLIENT, 0
			)
		except LookupError:
			return
		if obj != api.getFocusObject():
			api.moveMouseToNVDAObject(obj)
			api.setMouseObject(obj)
			winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0, None, None)
			winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None)
Ejemplo n.º 35
0
def rightMouseButton(o):
	""" make a right click
	@param o the object to click on"""
	# We get the object idea because we cannot act to the object dirrectly
	IDChild =o.IAccessibleChildID
	# We have to get the parent, this is a particularity.
	o=o.parent
	# We get the shild object location which has IDChild as id
	(x,y,l,h)=o.IAccessibleObject.accLocation(IDChild)
	#We calculate the center of the shild object
	x,y=int (x+l/2),int (y+h/2)
	# We move the cursor
	winUser.setCursorPos (x,y)
	# We make the right click event
	winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTDOWN,0,0,None,None)
	# Then, the release button event
	winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTUP,0,0,None,None)
	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
Ejemplo n.º 37
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")
    def script_TCAvolu(self, gesture):
        fg = api.getForegroundObject()
        obj = fg.children[5].children[2].children[0].children[7]
        ui.message("el nombre es: {}".format(obj.name))

        api.moveMouseToNVDAObject(obj)
        keyboardHandler.KeyboardInputGesture.fromName("space").send()

        os.chdir(tsu.a_path)
        focus = api.getFocusObject()
        focus = focus.parent
        a = '''Red
Acceso a Internet'''
        if focus.name == a:
            recButton = focus.parent.next.firstChild
            api.moveMouseToNVDAObject(recButton)
            winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0, None, None)
            winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None)
Ejemplo n.º 39
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)
Ejemplo n.º 40
0
	def script_readOnlyEdit(self, gesture):
		where = self.getWhere()
		if hasattr(where, "IAccessibleChildID") and where.IAccessibleChildID == 9:
			cID = -1
		else:
			cID = None
		try:
			obj = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
				windowUtils.findDescendantWindow(
					api.getForegroundObject().windowHandle, visible=True, className="RichEdit20W", controlID=cID
				), winUser.OBJID_CLIENT, 0
			)
		except LookupError:
			return
		if obj != api.getFocusObject():
			api.moveMouseToNVDAObject(obj)
			api.setMouseObject(obj)
			winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0, None, None)
			winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None)
Ejemplo n.º 41
0
 def mouseClick(self, button="left"):
     if controlTypes.State.INVISIBLE in api.getMouseObject().states:
         return (False)
     if button == "left":
         winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 0, None, None)
         winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None)
         return (True)
     if button == "right":
         winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTDOWN, 0, 0, None,
                             None)
         winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTUP, 0, 0, None, None)
         return (True)
Ejemplo n.º 42
0
 def script_vuMeter(self, gesture):
     gesture.send()
     if isStarting():
         sayMessage(announce[3])
         return
     h = self.windowHandle
     hwnd = vuMeterHandle()
     repeat = getLastScriptRepeatCount()
     level = getTextFromWindow(hwnd)
     if level:
         if repeat == 0:
             sayMessage(announce[7] + ' : ' + level)
         elif repeat == 1:
             setFocus(hwnd)
             mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, None, None)
             mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, None, None)
             sayMessage(announce[19])
             #setFocus (h)
     else:
         sayMessage(announce[18])
Ejemplo n.º 43
0
def executeMouseEvent(flags, x, y, data=0):
	"""
	Mouse events generated with this rapper for L{winUser.mouse_event}
	will be ignored by NVDA.
	Consult https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-mouse_event
	for detailed parameter documentation.
	@param flags: Controls various aspects of mouse motion and button clicking.
		The supplied value should be one or a combination of the C{winUser.MOUSEEVENTF_*} constants.
	@type flags: int
	@param x: The mouse's absolute position along the x-axis
		or its amount of motion since the last mouse event was generated.
	@type x: int
	@param y: The mouse's absolute position along the y-axis
		or its amount of motion since the last mouse event was generated.
	@type y: int
	@param data: Additional data depending on what flags are specified.
		This defaults to 0.
	@type data: int
	"""
	with ignoreInjection():
		winUser.mouse_event(flags, x, y, data, None)
Ejemplo n.º 44
0
def changePageTab (h,sens):
	""" Change the active tab
	@param h the handle of tab page
	@param sens : string, next or prior """
	#index =getPageTabActive ()[-1]
	index=listPageTab.index(getPageTabActive(h))
	if sens =="next":
		index+=1
	else:
		index-=1

	index %= len(listPageTab)

	(x, y, l, h) = NVDAObjects.IAccessible.getNVDAObjectFromEvent(h,-4,0).location
	x=x+(1,3,5,7,9)[index]*l/10
	y=y+h/2
	winUser.setCursorPos (x,y)
	winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN,0,0,None,None)
	winUser.mouse_event (winUser.MOUSEEVENTF_LEFTUP,0,0,None,None)

	#announces the new tab
	ui.message(listPageTab[index])
Ejemplo n.º 45
0
	def script_touch_rightClick(self, gesture):
		self.etsDebugOutput("etouch: attempting to perform right-click")
		obj=api.getNavigatorObject() 
		try:
			p=api.getReviewPosition().pointAtStart
		except (NotImplementedError, LookupError):
			p=None
		if p:
			x=p.x
			y=p.y
		else:
			try:
				(left,top,width,height)=obj.location
			except:
				# Translators: Reported when the object has no location for the mouse to move to it.
				ui.message(_("object has no location"))
				return
			x=left+(width/2)
			y=top+(height/2)
		self.etsDebugOutput("etouch: mouse point found at %s, %s"%(x, y))
		winUser.setCursorPos(x,y)
		winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTDOWN,0,0,None,None)
		winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTUP,0,0,None,None)
Ejemplo n.º 46
0
	def script_leftMouseClick(self,gesture):
		ui.message(_("left click"))
		winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN,0,0,None,None)
		winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP,0,0,None,None)
Ejemplo n.º 47
0
	def script_contextMenu(self, gesture):
		api.moveMouseToNVDAObject(self)
		api.setMouseObject(self)
		winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTDOWN,0,0,None,None)
		winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTUP,0,0,None,None)
Ejemplo n.º 48
0
	def script_rightMouseClick(self,gesture):
		ui.message(_("right click"))
		winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTDOWN,0,0,None,None)
		winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTUP,0,0,None,None)