本文整理汇总了Python中winUser.setCursorPos函数的典型用法代码示例。如果您正苦于以下问题:Python setCursorPos函数的具体用法?Python setCursorPos怎么用?Python setCursorPos使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setCursorPos函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: script_showSelectionOptions
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
示例2: event_gainFocus
def event_gainFocus(self):
if mouseHandler.lastMouseEventTime < time.time() - 0.2:
# This focus change was not caused by a mouse event.
# If the mouse is on another toolbar control, the notification area toolbar will rudely
# bounce the focus back to the object under the mouse after a brief pause.
# Moving the mouse to the focus object isn't a good solution because
# sometimes, the focus can't be moved away from the object under the mouse.
# Therefore, move the mouse out of the way.
winUser.setCursorPos(0, 0)
if self.role == controlTypes.ROLE_TOOLBAR:
# Sometimes, the toolbar itself receives the focus instead of the focused child.
# However, the focused child still has the focused state.
for child in self.children:
if child.hasFocus:
# Redirect the focus to the focused child.
eventHandler.executeEvent("gainFocus", child)
return
# We've really landed on the toolbar itself.
# This was probably caused by moving the mouse out of the way in a previous focus event.
# This previous focus event is no longer useful, so cancel speech.
speech.cancelSpeech()
if eventHandler.isPendingEvents("gainFocus"):
return
super(NotificationArea, self).event_gainFocus()
示例3: mouseEvents
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)
示例4: _activateNVDAObject
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
示例5: showGui
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)
示例6: moveMouseToNVDAObject
def moveMouseToNVDAObject(obj):
"""Moves the mouse to the given NVDA object's position"""
location=obj.location
if location and (len(location)==4):
(left,top,width,height)=location
x=(left+left+width)/2
y=(top+top+height)/2
winUser.setCursorPos(x,y)
示例7: _setCaretOffset
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)
示例8: _setCaretOffset
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)
示例9: doAction
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
示例10: activate
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)
示例11: _activateNVDAObject
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")
示例12: script_clickButtonCancel
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)
示例13: rightMouseButton
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)
示例14: _activateNVDAObject
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")
示例15: script_moveMouseToNavigatorObject
def script_moveMouseToNavigatorObject(self,gesture):
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:
ui.message(_("object has no location"))
return
x=left+(width/2)
y=top+(height/2)
winUser.setCursorPos(x,y)
mouseHandler.executeMouseMoveEvent(x,y)