Ejemplo n.º 1
0
 def _process_recognition(self, value, extras): 
   getPassword = Key("w-b/10, s-tab/10, right:8/10, enter, c-f/10") + value + Key('enter/10, escape/10, c-c/10, a-tab/10')
   getPassword.execute()
   clipboard = Clipboard()
   clipboard.copy_from_system(clear = True)
   password = clipboard.get_text()
   action = Text(password)
   action.execute()
Ejemplo n.º 2
0
def getFile(text=None):
    open_get_file_dialog = Key("cas-n")
    if text:
        open_get_file_dialog.execute()
        file_name = str(text).lower()
        Text(file_name).execute()
    else:
        open_get_file_dialog.execute()
Ejemplo n.º 3
0
class GitterRule(MergeRule):
    pronunciation = "Gitter"

    mapping = {
        "bold":
            R(Text("****") + Key("left:2"), rdescript="Gitter: Bold"),
        "emphasize":
            R(Text("**") + Key("left"), rdescript="Gitter: Italicize"),
        # "header":           R(Text( "" ), rdescript="Gitter: Header"), # H1 ## H2 ### H3
        "insert item":
            R(Text("* "), rdescript="Gitter: Insert Item"),
        "block quote":
            R(Text("> "), rdescript="Gitter: Block Quote"),
        "mention":
            R(Text("@"), rdescript="Gitter: Mention"),
        "insert link":
            R(Text("[]()") + Key("left:3"), rdescript="Gitter: Insert Link"),
        "insert image":
            R(Text("![]()") + Key("left:3"), rdescript="Gitter: Insert Image"),
        "insert code":
            R(Text("``") + Key("left"), rdescript="Gitter: Insert Code"),
        "formatted code":
            R(Text("```") + Key("s-enter"), rdescript="Gitter: Formatted Code"),
    }
    extras = [
        Dictation("text"),
    ]
    Defaults = {}
Ejemplo n.º 4
0
class CodeMappings(MappingRule):
    mapping = {
        'tab <number>': Function(calculateSlotNumber),
        'Activity': Key('c-1'),
        'chat': Key('c-2'),
        'Teams': Key('c-3'),
        'Calendar': Key('c-4'),
        'snurch': Key('c-e'),
        'goat': Key('c-g'),
        'Filter': Key('cs-f'),
        'make call': Key('cs-c') + Key('csa-slash'),
        '<text>': Text("%(text)s "),
    }
    extras = [
        Integer('tab', 1, 10),
        Integer('number', 1, 9999),
        Dictation("text")
    ]
Ejemplo n.º 5
0
class MSWordRule(MergeRule):
    pronunciation = "Microsoft Word"

    mapping = {
        "insert image":              R(Key("alt, n, p"), rdescript="Word: Insert Image"),
        
        
        }
    extras = [
              Dictation("dict"),
              IntegerRefST("n",1, 100),
             ]
    defaults ={"n": 1, "dict":"nothing"}
Ejemplo n.º 6
0
class KeysOnlyRule(MappingRule):
    exported = False
    mapping = {k: Key(v) for k, v in lib.mappings.keys.items()}
    mapping.update({"<formatType> <text>": Function(format_text)})
    # mapping.update({"sh":Mouse("<0,0>,left")})
    extras = [
        Dictation("text"),
        Choice("formatType", formatMap),
        IntegerRef("n", 1, 100),  # Times to repeat the sequence.
    ]
    defaults = {
        "n": 1,
    }
Ejemplo n.º 7
0
class GlobalRule(MappingRule):
    mapping = {
        '[<text>] go to sleep': Function(go_to_sleep),
        'mouse': Key('f3,f4/350,f4'),
        "touch": Mouse("left"),
        "touch two": Mouse("left:2"),
        'touch are': Mouse('right'),
        "touch mid": Mouse("middle"),
        "[<n>] scroll down": (Mouse("wheeldown") + Pause('5')) * Repeat(extra='n') * 2,
        "[<n>] scroll up": (Mouse("wheelup") + Pause('5')) * Repeat(extra='n') * 2,
        "[<n>] scroll right": (Mouse("wheelright") + Pause('5')) * Repeat(extra='n') * 2,
        "[<n>] scroll left": (Mouse("wheelleft") + Pause('5')) * Repeat(extra='n') * 2,
        "drag": Mouse("left:down"),
        "drop": Mouse("left:up"),
        "[<n>] alt tab": Key("alt:down,tab/50:%(n)d/50,alt:up"),
        "alt tab show": Key("alt:down,tab/10,s-tab"),
        'reload natlink': Function(reload_natlink),
    }
    extras = [
        IntegerRef('n', 1, 101, default=1),
        Dictation('text'),
    ]
Ejemplo n.º 8
0
def selection_to_bib(ref_type, bib_path):
    Key("c-c/20").execute()
    cb = Clipboard.get_system_text()
    if ref_type == "book":
        ref = book_citation_generator.citation_from_name(cb)
    elif ref_type == "paper":
        ref = bibtexer.bib_from_title(cb)
    elif ref_type == "link":
        ref = bibtexer.bibtex_from_link(cb)
    with codecs.open(bib_path, encoding="utf-8", mode="a") as f:
        f.write(ref)
    print("Reference added:\n" + ref)
    Clipboard.set_system_text(bibtexer.get_tag(ref))
Ejemplo n.º 9
0
class TaskBar(MappingRule):
    
    mapping = {
        "Dora": Key("w-1"),
        "outlook": Key("w-2"),
        "chromie": Key("w-3"),
        "slacker": Key("w-4"),
        "teamer": Key("w-5"),
        "viz. code": Key("w-6"),
        "termie": Key("w-7"),
    }
Ejemplo n.º 10
0
def defineMethod(text, _node):
    commands = _node.words()
    method_index = commands.index("method")
    modifiers_string = getModifiers(commands[:method_index])
    formatted_class_name = ""
    if text:
        format_me = str(text)
        if len(commands) > method_index + 1:
            format_command = commands[method_index + 1]
            if (format_command != "pascal") and (format_command !="snake"):
                format_command = "camel"  # default
            formatted_class_name = utils.text_to_case(format_command, format_me)
    (Text(modifiers_string + formatted_class_name + "() {") + Key("enter, up, end, left:3")).execute()
Ejemplo n.º 11
0
def defineClass(text, _node):
    commands = _node.words()
    class_index = commands.index("class")
    modifiers_string = getModifiers(commands[:class_index])
    formatted_class_name = ""
    if text:
        format_me = str(text)
        if len(commands) > class_index + 1:
            format_command = commands[class_index + 1]
            if (format_command != "camel") and (format_command !="snake"):
                format_command = "pascal"  # default
            formatted_class_name = utils.text_to_case(format_command, format_me)
    (Text(modifiers_string + "class " + formatted_class_name + " {") + Key("enter")).execute()
Ejemplo n.º 12
0
class FlashDevelopCCR(MergeRule):
    pronunciation = "flash develop test"
    mwith = [Navigation().get_name()]
    
    mapping = {
            "[go to] line <n>":                         R(Key("c-g") + Pause("50") + Text("%(n)d") + Key("enter"), 
                                                          rdescript="FlashDevelop: Go To Line"),
        }
    extras = [
              Dictation("text"),
              IntegerRefST("n", 1, 1000),
             ]
    defaults = {"n": 1}
Ejemplo n.º 13
0
class CommandRule(MappingRule):
    mapping = {
        "dragonfly add buffer": Exec("dragonfly-add-buffer"),
        "dragonfly add word": Exec("dragonfly-add-word"),
        "dragonfly blacklist word": Exec("dragonfly-blacklist-word"),
        "Foreclosure next": Exec("4clojure-next-question"),
        "Foreclosure previous": Exec("4clojure-previous-question"),
        "Foreclosure check": Exec("4clojure-check-answers"),
        "confirm": Text("yes") + Key("enter"),
        "deny": Text("no") + Key("enter"),
        "relative line numbers": Exec("linum-relative-toggle"),
        "revert buffer": Exec("revert-buffer"),
        "exit out of Emacs": Key("c-x, c-c"),
        }
    extras = [
        IntegerRef("n", 1, 20),
        IntegerRef("line", 1, 10000),
        Dictation("text"),
        ]
    defaults = {
        "n": 1,
        }
Ejemplo n.º 14
0
class ObjectRule(MappingRule):
    exported = False
    mapping = {
        "[<n>] <modifier> <object>": Key("%(n)d, %(modifier)s, %(object)s")
    }
    extras = [
        IntegerRef("n", 1, 10),
        modifier.modifierChoice("modifier"),
        object.objectChoice("object"),
    ]
    defaults = {
        "n": 1,
    }
Ejemplo n.º 15
0
 def __init__(self, slack_n, outlook_n):
     self.slack = Key("w-" + slack_n + "/100")
     self.my_team = Key("c-2/30")
     self.myself = Key("cs-t/100") + Text("you") + Key("enter/50")
     self.msg_field = Mouse("[400, 1000]")  # sometimes needs to be selected
     self.copy_msg = Key("up/30, c-a/30, c-c/30")
     self.outlook = Key("w-" + outlook_n + "/50")
     self.copy_from_slack = self.slack + self.my_team + self.myself + self.msg_field + self.copy_msg
Ejemplo n.º 16
0
class NERDTreeRule(MappingRule):
    exported = True
    mapping = {
        "nerd open": Key('o'),
        "nerd open split": Key('i'),
        "nerd open vertical": Key('s'),
        "nerd open tab": Key('t'),
        "nerd change directory": Key('c, d'),
        "nerd set directory": Key('C'),
        "nerd toggle": Key('colon') + Text('NERDTreeToggle') + Key('enter'),
        # use insert start commandto go into change node mode
        # nerd change node
    }
    extras = []
    default = {}
Ejemplo n.º 17
0
def getFile(text=None):
    open_get_file_dialog = Key("cas-n")
    if text:
        open_get_file_dialog.execute()
        file_name = str(text).lower()
        Text(file_name).execute()
    else:
        open_get_file_dialog.execute()
Ejemplo n.º 18
0
class GlobalMovementRule(MappingRule):
    mapping = {
        'up [<n>]': Key('up:%(n)d'),
        'down [<n>]': Key('down:%(n)d'),
        'left [<n>]': Key('left:%(n)d'),
        'right [<n>]': Key('right:%(n)d'),
        'home': Key('home'),
        'end': Key('end'),
        'enter [<n>]': Key('enter:%(n)d'),
    }
    extras = [IntegerRef('n', 1, 9999)]
    defaults = {'n': 1}
Ejemplo n.º 19
0
class WindowRule(MappingRule):
    name = "gvim_window"
    mapping = {
        # window navigation commands
        "window left": Key("c-w,h"),
        "window right": Key("c-w,l"),
        "window up": Key("c-w,k"),
        "window down": Key("c-w,j"),
        "increase window vertical":
        Key("colon") + Text('res +10') + Key('enter'),

        # window creation commands
        "window split": Key("c-w,s"),
        "window vertical split": Key("c-w,v"),
    }
    extras = []
Ejemplo n.º 20
0
class SlackMapping(MappingRule):
    mapping = {
        # "new (thing | tab)": Key("c-t"),
        # "new window": Key("c-n"),
        # "reopen tab": Key("cs-t"),
        # "(next | nex) (tab | ab) [<n>]": Key("c-pgdown:%(n)d"),
        # "(previous | preev) tab [<n>]": Key("c-pgup:%(n)d"),
        # "show tab <tab>": Key("c-%(tab)d"),
        "switch <text>": Key("c-k/25") + Text("%(text)s") + Key("enter"),
        "show switch": Key("c-k"),
        "left (pain | pane)": Key("f6/10:3"),

        # "open <w> [<x>] [<y>] [<z>]": Key("cs-space/" + click_by_voice_delay) + Function(printNumber) + Key("enter"),  # click by voice
        # "open focus <w> [<x>] [<y>] [<z>]": Key("cs-space/" + click_by_voice_delay) + Function(printNumberFocus) + Key("enter"),  # click by voice
    }
    extras = [
        Integer("n", 1, 50),
        Integer("number", 1, 9999),
        Dictation("text"),
    ]
    defaults = {
        "n": 1,
    }
Ejemplo n.º 21
0
def drop_keep_clipboard(nnavi500, nexus):
    if nnavi500 == 1:
        Key("c-v").execute()
    else:
        max_tries = 20
        key = str(nnavi500)
        cb = Clipboard(from_system=True)
        for i in range(0, max_tries):
            failure = False
            try:
                if key in nexus.clip:
                    Clipboard.set_system_text(nexus.clip[key])
                    Key("c-v").execute()
                    time.sleep(
                        settings.SETTINGS["miscellaneous"]["keypress_wait"] /
                        1000.)
                else:
                    dragonfly.get_engine().speak("slot empty")
            except Exception:
                failure = True
            if not failure:
                break
        cb.copy_to_system()
Ejemplo n.º 22
0
def text_nav(modifier, direction, n50, extreme):
    k = ""
    if extreme:
        if direction in ["left", "up"]:
            k = k + "home"
        else:
            k = k + "end"
        if direction in ["up", "down"]:
            k = "c-" + k
    else:
        k = str(direction) + ":" + str(n50)
    if modifier:
        k = str(modifier) + k.replace("c-", "")
    Key(k).execute()
Ejemplo n.º 23
0
def launch(hmc_type, callback, data=None):
    from dragonfly import (WaitWindow, FocusWindow, Key)
    instructions = _get_instructions(hmc_type)
    if data != None:
        instructions.append(data)
    Popen(instructions)

    hmc_title = _get_title(hmc_type)
    WaitWindow(title=hmc_title, timeout=5).execute()
    FocusWindow(title=hmc_title).execute()
    Key("tab").execute()

    from caster.asynch.hmc import squeue
    squeue.add_query(callback)
Ejemplo n.º 24
0
def get_selected_files(folders=False):
    '''
    Copy selected (text or file is subsequently of interest) to a fresh clipboard
    '''
    if WIN32 or LINUX:
        cb = Clipboard(from_system=True)
        cb.clear_clipboard()
        Key("c-c").execute()
        time.sleep(0.1)
        files = get_clipboard_files(folders)
        cb.copy_to_system()
        return files
    else:
        printer.out("get_selected_files: Not implemented for OS")
Ejemplo n.º 25
0
class PythonControlStructures(MappingRule):
    mapping = {
        "if": Text("if cond:") + Key("enter"),
        "for loop": Text("for i in iter:") + Key("enter"),
        "function": Text("def function():") + Key("enter"),
        "class": Text("class cls(object):") + Key("enter"),
        "init": Text("def __init__(self):") + Key("enter"),
        "main": Text("if __name__ == '__main__':") + Key("enter"),
    }
Ejemplo n.º 26
0
class MobaXtermMapping(MappingRule):

    mapping = {
        "next tab [<t>]":
        Key("c-tab:%(t)d"),
        "(preev | previous) tab [<t>]":
        Key("cs-tab:%(t)d"),
        "close tab [<t>]":
        Key("ca-q:%(t)d"),
        "Denny triage":
        Text("cd /usr/share/indeni-knowledge/stable/automation") +
        Key("enter"),
        "Ansible logs":
        Text("cd /usr/share/indeni-services/logs/ansible") + Key("enter"),
        "Denny knowledge":
        Text("cd /usr/share/indeni-knowledge") + Key("enter"),
        "Denny server":
        Text("cd /usr/share/indeni") + Key("enter"),
        "Denny collector":
        Text("cd /usr/share/indeni") + Key("enter"),
        "restart server":
        Text("sudo res") + Key("enter"),
        "stop server":
        Text("sudo res stop") + Key("enter"),
    }

    extras = [
        Integer("t", 1, 50),
        Dictation("text"),
        Dictation("text2"),
        IntegerRef("n", 1, 50000),
        Integer("w", 0, 10),
        Integer("x", 0, 10),
        Integer("y", 0, 10),
        Integer("z", 0, 10)
    ]
    defaults = {"t": 1, "text": "", "text2": ""}
Ejemplo n.º 27
0
    def find(self,
             back,
             go,
             text=None,
             punctuation=None,
             a=None,
             b=None,
             c=None):
        '''set direction'''

        key = "b" if back else "o"
        Key("a-" + key).execute()
        '''figure out what to search for'''
        if text is not None:
            text = str(text)
            '''simple vowel-removal regex'''
            if self.regex:
                text = re.sub("[aeiouAEIOU]+", r".*", text)
                if text.endswith(r".*"):
                    text = text[:-2]
        elif punctuation is not None:
            text = str(punctuation)
            self.regex_off()
        elif a is not None:
            a = str(a)
            b = str(b) if b is not None else ""
            c = str(c) if c is not None else ""
            text = a + b + c
            self.regex_off()
        Text(text).execute()
        '''"go" indicates that we should keep looking'''
        if go:
            u = UntilCancelled(Key("enter"), 2)
            u.show = False
            u.execute()
        else:
            Key("enter, escape").execute()
Ejemplo n.º 28
0
class EmacsGroupingSymbols(MappingRule):
    mapping = {
        'angle': Key('langle, rangle, left'),
        'arc': Key('lparen, rparen, left'),
        'curly': Key('lbrace, rbrace, left'),
        'double': Key('dquote, dquote, left'),
        'single': Key('squote, squote, left'),
        'square': Key('lbracket, rbracket, left'),
    }
Ejemplo n.º 29
0
class NetrwRule(MappingRule):
    exported = True
    mapping = {
        "explore here": Text(":Explore") + Key("enter"),
        "explore fault": Text(":Vexplore") + Key("enter"),
        "explore split": Text(":Sexplore") + Key("enter"),
        "explore tab": Text(":Texplore") + Key("enter"),
        "explore back": Text(":Rexplore") + Key("enter"),
        "create net file": Key('%%'),
        "create net directory": Key('d')
    }
    extras = []
    defaults = {}
Ejemplo n.º 30
0
class InsertModeStartRule(MappingRule):
    exported = True
    mapping = {
        "change <motion> [<text>]": Key("c") + execute_rule('motion') + Text('%(text)s'),
        "change <object> [<text>]": Key("c") + execute_rule('object') + Text('%(text)s'),
        "change line [<text>]": Key("c,c") + Text('%(text)s'),

        "insert [<text>]": Key("i") + Text('%(text)s'),
        "prepend [<text>]": Key("I") + Text('%(text)s'),
        "after [<text>]": Key("a") + Text('%(text)s'),
        "append [<text>]": Key("A") + Text('%(text)s'),
        "oh [<text>]": Key("o") + Text('%(text)s'),
        "bo [<text>]": Key("O") + Text('%(text)s'),

        "insert last [<text>]": Key("g, i") + Text('%(text)s'),
    }
    extras = [
        RuleRef(rule = motion.MotionRule(name = "insert_motion"), name = "motion"),
        RuleRef(rule = object.ObjectRule(name = "insert_object"), name = "object"),
        Dictation("text"),
    ]
    defaults = {
        "text": "",
    }
 def do_scratch_n_times(self, n):
     for _ in range(n):
         try:
             # Get the number of characters to delete from the current
             # window's stack. Discard the state flags.
             scratch_number, _ = self._get_window_stack().pop()
             Key("backspace:%d" % scratch_number).execute()
         except IndexError:
             handle = self._current_window_handle
             window = Window.get_window(handle)
             exe = os.path.basename(window.executable)
             title = window.title
             print("Nothing in scratch memory for %r window "
                   "(title=%r, id=%d)" % (exe, title, handle))
             break
Ejemplo n.º 32
0
class GlobalClionMappings(MappingRule):
    mapping = {
        #ide shortcuts
        "helper": Key("a-enter"),
        "reformat": Key("ctrl:down, a-l, ctrl:up"),
        "project": Key("ctrl:down, tab:down/10,1/10,tab:up,ctrl:up"),
        "rename": Key("shift:down,f6/10, shift:up"),
        "run": Key("s-f10"),
        "debug": Key("s-f9"),
        "build": Key("c-f9"),
        "stop": Key("c-f2"),
    }
    extras = [
        Dictation("text"),
        Integer("n", 0, 50),
        Integer("line", 1, 10000)
    ]
Ejemplo n.º 33
0
def find(letter, n):
	f = Key('f')
	for i in range(n):
		f.execute()
		letter.execute()