Exemple #1
0
    def rule_gettaskposition(self, words):
        """
        #commands for recording taskbar positions:
        get task position {taskcount}
        """
        # getting the task positions (use with 1 and with another number)
        # position mouse on task number or clock and speak the command
        # june 2016: removed the obsolete clock commands.
        # first time only, or after changes of taskbar position
        count = self.getNumberFromSpoken(words[-1])
        x, y = natlink.getCursorPos()
        if count in self.taskCounts:
            print '%s, setting task position: %s' % (self.name, count)
        else:
            print '%s, not a valid "count" for setting task position: %s' % (
                self.name, count)
            return
        if count == 1:
            print 'setting mouseX1: ', x
            print 'setting mouseY1: ', y
            setPosition('mousex1', x)
            setPosition('mousey1', y)
        else:
            mousex1 = getPosition('mousex1')
            mousey1 = getPosition('mousey1')

            mouseXdiff = int((x - mousex1) / (count - 1))
            mouseYdiff = int((y - mousey1) / (count - 1))
            print 'setting mouseXdiff: ', mouseXdiff
            print 'setting mouseYdiff: ', mouseYdiff
            setPosition('mousexdiff', mouseXdiff)
            setPosition('mouseydiff', mouseYdiff)
 def rule_gettaskordocumentposition(self, words):
     """
     #commands for recording taskbar position (global)
     #or the document position (program specific)
     get (task|document) position ({taskdoccount})
     """
     # getting the task positions (use with 1 and with another number)
     # position mouse on task number or clock and speak the command
     # first time only, or after changes of taskbar position
     count = self.getNumberFromSpoken(words[-1])
     doTaskbar = self.hasCommon(words[1], 'task')
     doDocument = self.hasCommon(words[2], 'document')
     if count not in self.taskdocCounts:
         print '_tasks, gettaskordocumentposition: no valid count (%s): ', count
         return
     if doTaskbar:
         x, y = natlink.getCursorPos()
         if count == 1:
             print 'setting mouseX1: ', x
             print 'setting mouseY1: ', y
             setPosition('mousex1', x)
             setPosition('mousey1', y)
         else:
             mousex1 = getPosition('mousex1')
             mousey1 = getPosition('mousey1')
             
             mouseXdiff = int((x - mousex1 )/(count-1))
             mouseYdiff = int((y - mousey1 )/(count-1))
             print 'setting mouseXdiff: ', mouseXdiff
             print 'setting mouseYdiff: ', mouseYdiff
             setPosition('mousexdiff', mouseXdiff)
             setPosition('mouseydiff', mouseYdiff)
     elif doDocument:
         prog, title, topchild, windowHandle = natqh.getProgInfo()
         if not prog:
             print '_tasks, gettaskordocumentposition: no program in foreground, so cannot get document position for program: %s (title:%s)'% (prog, title)
             return
         x, y = natlink.getCursorPos()
         if count == 1:
             print 'setting mouseX1: ', x
             print 'setting mouseY1: ', y
             setPosition('mousex1', x, prog=prog)
             setPosition('mousey1', y, prog=prog)
         else:
             mousex1 = getPosition('mousex1', prog=prog)
             mousey1 = getPosition('mousey1', prog=prog)
             
             mouseXdiff = int((x - mousex1 )/(count-1))
             mouseYdiff = int((y - mousey1 )/(count-1))
             print 'setting mouseXdiff: ', mouseXdiff
             print 'setting mouseYdiff: ', mouseYdiff
             setPosition('mousexdiff', mouseXdiff, prog=prog)
             setPosition('mouseydiff', mouseYdiff, prog=prog)
     else:
         print 'invalid word in in gettaskordocumentposition: %s'% words
         return
Exemple #3
0
    def rule_getdocumentposition(self, words):
        """
        #commands for recording a document position, application specific
        get document position {documentcount}
        """
        # getting the task positions (use with 1 and with another number)
        # position mouse on task number or clock and speak the command
        # first time only, or after changes of taskbar position
        prog, title, topchild, classname, hndle = natqh.getProgInfo()
        if not prog:
            print(
                '%s, no valid program for setting document position: %s (title:%s)'
                % (self.name, prog, title))
            return
        count = self.getNumberFromSpoken(words[-1])
        x, y = natlink.getCursorPos()
        if count in self.documentCounts:
            print('%s, setting document position %s for program: %s' %
                  (self.name, count, prog))
        else:
            print(
                '%s, cannot set document position "%s" for program: %s (invalid count)'
                % (self.name, count, prog))
            return
        if count == 1:
            print('setting mouseX1: ', x)
            print('setting mouseY1: ', y)
            setPosition('mousex1', x, prog=prog)
            setPosition('mousey1', y, prog=prog)
        else:
            mousex1 = getPosition('mousex1', prog=prog)
            mousey1 = getPosition('mousey1', prog=prog)

            mouseXdiff = int((x - mousex1) / (count - 1))
            mouseYdiff = int((y - mousey1) / (count - 1))
            print('setting mouseXdiff: ', mouseXdiff)
            print('setting mouseYdiff: ', mouseYdiff)
            setPosition('mousexdiff', mouseXdiff, prog=prog)
            setPosition('mouseydiff', mouseYdiff, prog=prog)
Exemple #4
0
    def rule_gettaskposition(self, words):
        """
        #commands for recording taskbar and clock positions:
        'get task position' ({taskcount}|clock)
        """
        # getting the task positions (use with 1 and with another number)
        # position mouse on task number or clock and speak the command
        # first time only, or after changes of taskbar position
        count = self.getNumberFromSpoken(words[-1])
        x, y = natlink.getCursorPos()
        if count in self.taskCounts:
            print 'setting task position: ', count
        else:
            count = 0
        if count == 1:
            print 'setting mouseX1: ', x
            print 'setting mouseY1: ', y
            setPosition('mousex1', x)
            setPosition('mousey1', y)
        elif count:
            mousex1 = getPosition('mousex1')
            mousey1 = getPosition('mousey1')

            mouseXdiff = int((x - mousex1) / (count - 1))
            mouseYdiff = int((y - mousey1) / (count - 1))
            print 'setting mouseXdiff: ', mouseXdiff
            print 'setting mouseYdiff: ', mouseYdiff
            setPosition('mousexdiff', mouseXdiff)
            setPosition('mouseydiff', mouseYdiff)
        elif self.hasCommon(words, 'clock'):
            print 'clock position:', x, y
            setPosition('clockx', x)
            setPosition('clocky', y)
        else:
            print 'invalid option in gettaskposition: %s' % words
            return
Exemple #5
0
 def rule_gettaskposition(self, words):
     """
     #commands for recording taskbar and clock positions:
     'get task position' ({taskcount}|clock)
     """
     # getting the task positions (use with 1 and with another number)
     # position mouse on task number or clock and speak the command
     # first time only, or after changes of taskbar position
     count = self.getNumberFromSpoken(words[-1])
     x, y = natlink.getCursorPos()
     if count in self.taskCounts:
         print 'setting task position: ', count
     else:
         count = 0
     if count == 1:
         print 'setting mouseX1: ', x
         print 'setting mouseY1: ', y
         setPosition('mousex1', x)
         setPosition('mousey1', y)
     elif count:
         mousex1 = getPosition('mousex1')
         mousey1 = getPosition('mousey1')
         
         mouseXdiff = int((x - mousex1 )/(count-1))
         mouseYdiff = int((y - mousey1 )/(count-1))
         print 'setting mouseXdiff: ', mouseXdiff
         print 'setting mouseYdiff: ', mouseYdiff
         setPosition('mousexdiff', mouseXdiff)
         setPosition('mouseydiff', mouseYdiff)
     elif self.hasCommon(words,'clock'):
         print 'clock position:', x, y
         setPosition('clockx', x)
         setPosition('clocky', y)
     else:
         print 'invalid option in gettaskposition: %s'% words
         return