示例#1
0
def relativeMotion(x, y, mouseDelay=None):
    logger.log("Mouse relative motion of (%s,%s)" % (x, y))
    registry.generateMouseEvent(x, y, 'rel')
    if mouseDelay:
        doDelay(mouseDelay)
    else:
        doDelay()
示例#2
0
def keyCombo(comboString):
    """
    Generates the appropriate keyboard events to simulate a user pressing the
    specified key combination.

    comboString is the representation of the key combo to be generated.
    e.g. '<Control><Alt>p' or '<Control><Shift>PageUp' or '<Control>q'
    """
    strings = []
    for s in comboString.split('<'):
        if s:
            for S in s.split('>'):
                if S:
                    S = keyNameAliases.get(S.lower(), S)
                    strings.append(S)
    for s in strings:
        if not hasattr(Gdk, s):
            if not hasattr(Gdk, 'KEY_' + s):
                raise ValueError("Cannot find key %s" % s)
    modifiers = strings[:-1]
    finalKey = strings[-1]
    for modifier in modifiers:

        code = keyNameToKeyCode(modifier)
        registry.generateKeyboardEvent(code, None, KEY_PRESS)
    code = keyNameToKeyCode(finalKey)
    registry.generateKeyboardEvent(code, None, KEY_PRESSRELEASE)
    for modifier in modifiers:
        code = keyNameToKeyCode(modifier)
        registry.generateKeyboardEvent(code, None, KEY_RELEASE)
    doDelay()
示例#3
0
def release(x, y, button=1, check=True):
    """
    Synthesize a mouse button release at (x,y)
    """
    if check:
        checkCoordinates(x, y)
    logger.log("Mouse button %s release at (%s,%s)" % (button, x, y))
    registry.generateMouseEvent(x, y, 'b%sr' % button)
    doDelay()
示例#4
0
def doubleClick(x, y, button=1, check=True):
    """
    Synthesize a mouse button double-click at (x,y)
    """
    if check:
        checkCoordinates(x, y)
    logger.log("Mouse button %s doubleclick at (%s,%s)" % (button, x, y))
    registry.generateMouseEvent(x, y, 'b%sd' % button)
    doDelay()
示例#5
0
def click(x, y, button=1, check=True):
    """
    Synthesize a mouse button click at (x,y)
    """
    if check:
        checkCoordinates(x, y)
    logger.log("Mouse button %s click at (%s,%s)" % (button, x, y))
    registry.generateMouseEvent(x, y, 'b%sc' % button)
    doDelay(config.actionDelay)
示例#6
0
文件: tree.py 项目: unal55/dogtail
 def deselect(self):
     """Deselects the Accessible."""
     try:
         parent = self.parent
     except AttributeError:
         raise NotImplementedError
     result = parent.querySelection().deselectChild(self.indexInParent)
     doDelay()
     return result
示例#7
0
def absoluteMotion(x, y, mouseDelay=None, check=True):
    """
    Synthesize mouse absolute motion to (x,y)
    """
    if check:
        checkCoordinates(x, y)
    logger.log("Mouse absolute motion to (%s,%s)" % (x, y))
    registry.generateMouseEvent(x, y, 'abs')
    if mouseDelay:
        doDelay(mouseDelay)
    else:
        doDelay()
示例#8
0
 def point(self, mouseDelay=None):
     """
     Move mouse cursor to the center of the widget.
     """
     pointX = self.position[0] + self.size[0] / 2
     pointY = self.position[1] + self.size[1] / 2
     logger.log("Pointing on %s %s at (%s,%s)" % (self.name, self.getLogString(), str(pointX), str(pointY)))
     rawinput.registry.generateMouseEvent(pointX, pointY, "abs")
     if mouseDelay:
         doDelay(mouseDelay)
     else:
         doDelay()
示例#9
0
文件: tree.py 项目: unal55/dogtail
 def point(self, mouseDelay=None):
     """
     Move mouse cursor to the center of the widget.
     """
     pointX = self.position[0] + self.size[0] / 2
     pointY = self.position[1] + self.size[1] / 2
     logger.log("Pointing on %s %s at (%s,%s)" %
                (self.name, self.getLogString(), str(pointX), str(pointY)))
     rawinput.registry.generateMouseEvent(pointX, pointY, 'abs')
     if mouseDelay:
         doDelay(mouseDelay)
     else:
         doDelay()
示例#10
0
def drag(fromXY, toXY, button=1, check=True):
    """
    Synthesize a mouse press, drag, and release on the screen.
    """
    logger.log("Mouse button %s drag from %s to %s" % (button, fromXY, toXY))

    (x, y) = fromXY
    press(x, y, button, check)
    # doDelay()

    (x, y) = toXY
    absoluteMotion(x, y, check=check)
    doDelay()

    release(x, y, button, check)
    doDelay()
示例#11
0
文件: tree.py 项目: unal55/dogtail
 def do(self):
     """
     Performs the given tree.Action, with appropriate delays and logging.
     """
     logger.log("%s on %s" % (self.name, self.node.getLogString()))
     if not self.node.sensitive:
         if config.ensureSensitivity:
             raise NotSensitiveError(self)
         else:
             nSE = NotSensitiveError(self)
             logger.log("Warning: " + str(nSE))
     if config.blinkOnActions:
         self.node.blink()
     result = self.__action.doAction(self.__index)
     doDelay(config.actionDelay)
     return result
示例#12
0
文件: tree.py 项目: unal55/dogtail
    def typeText(self, string):
        """
        Type the given text into the node, with appropriate delays and
        logging.
        """
        logger.log("Typing text into %s: '%s'" % (self.getLogString(), string))

        if self.focusable:
            if not self.focused:
                try:
                    self.grabFocus()
                except Exception:
                    logger.log("Node is focusable but I can't grabFocus!")
            rawinput.typeText(string)
        else:
            logger.log("Node is not focusable; falling back to inserting text")
            et = self.queryEditableText()
            et.insertText(self.caretOffset, string, len(string))
            self.caretOffset += len(string)
            doDelay()
示例#13
0
def doTypingDelay():
    doDelay(config.typingDelay)
示例#14
0
文件: tree.py 项目: unal55/dogtail
 def deselectAll(self):
     """Deselects all selected children."""
     result = self.querySelection().clearSelection()
     doDelay()
     return result
示例#15
0
文件: tree.py 项目: unal55/dogtail
 def selectAll(self):
     """Selects all children."""
     result = self.querySelection().selectAll()
     doDelay()
     return result
示例#16
0
文件: tree.py 项目: unal55/dogtail
 def fset(self, value):
     logger.log("Setting combobox %s to '%s'" % (self.getLogString(),
                                                 value))
     self.childNamed(childName=value).doActionNamed('click')
     doDelay()