Exemplo n.º 1
0
def send_input(n, action):
    s = control.nexus().comm.get_com("grids")

    int_a = int(action)
    response = None

    if int_a != 2:
        s.go(str(n))
    elif int_a == 2:
        response = s.retrieve_data_for_highlight(str(int(n)))

    s.kill()
    navigation.wait_for_grid_exit()

    if int_a == 0:
        Playback([(["mouse", "left", "click"], 0.0)]).execute()
    elif int_a == 1:
        Playback([(["mouse", "right", "click"], 0.0)]).execute()
    elif int_a == 2:
        x1 = response["l"] + 2
        x2 = response["r"]
        y = response["y"]
        Mouse("[{}, {}]".format(x1, y)).execute()
        time.sleep(0.1)
        Mouse("left:down").execute()
        Mouse("[{}, {}]".format(x2, y)).execute()
        time.sleep(0.1)
        Mouse("left:up").execute()
Exemplo n.º 2
0
def send_input(n, action, nexus):
    s = nexus.comm.get_com("grids")

    int_a = int(action)
    response = None

    if int_a != 2:
        s.go(str(n))
    elif int_a == 2:
        response = s.retrieve_data_for_highlight(str(int(n)))

    s.kill()
    grids.wait_for_death(settings.LEGION_TITLE)

    if int_a == 0:
        Playback([(["mouse", "left", "click"], 0.0)]).execute()
    elif int_a == 1:
        Playback([(["mouse", "right", "click"], 0.0)]).execute()
    elif int_a == 2:
        x1 = response["l"] + 2
        x2 = response["r"]
        y = response["y"]

        win32api.SetCursorPos((x1, y))
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x1, y, 0, 0)
        time.sleep(0.5)
        win32api.SetCursorPos((x2, y))
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x2, y, 0, 0)
Exemplo n.º 3
0
class WindowManagementRule(MappingRule):
    mapping = {
        'minimize':
            R(Playback([(["minimize", "window"], 0.0)])),
        'maximize':
            R(Playback([(["maximize", "window"], 0.0)])),
        "remax":
            R(Key("a-space/10,r/10,a-space/10,x")),

        # Workspace management
        "show work [spaces]":
            R(Key("w-tab")),
        "(create | new) work [space]":
            R(Key("wc-d")),
        "close work [space]":
            R(Key("wc-f4")),
        "close all work [spaces]":
            R(Function(windows_virtual_desktops.close_all_workspaces)),
        "next work [space] [<n>]":
            R(Key("wc-right"))*Repeat(extra="n"),
        "(previous | prior) work [space] [<n>]":
            R(Key("wc-left"))*Repeat(extra="n"),

        "go work [space] <n>":
            R(Function(windows_virtual_desktops.go_to_desktop_number)),
        "send work [space] <n>":
            R(Function(windows_virtual_desktops.move_current_window_to_desktop)),
        "move work [space] <n>":
            R(Function(windows_virtual_desktops.move_current_window_to_desktop, follow=True)),
    }

    extras = [
        IntegerRefST("n", 1, 20, default=1),
    ]
Exemplo n.º 4
0
class WindowManagementRule(MappingRule):
    mapping = {
        'minimize':
            R(Playback([(["minimize", "window"], 0.0)])),
        'maximize':
            R(Playback([(["maximize", "window"], 0.0)])),
        "remax":
            R(Key("a-space/10,r/10,a-space/10,x")),
    }
Exemplo n.º 5
0
def send_input(pre, color, n, action, nexus):
    s = nexus.comm.get_com("grids")
    s.move_mouse(int(pre), int(color), int(n))
    s.kill()
    grids.wait_for_death(settings.RAINBOW_TITLE)
    int_a = int(action)
    if int_a == 0:
        Playback([(["mouse", "left", "click"], 0.0)]).execute()
    elif int_a == 1:
        Playback([(["mouse", "right", "click"], 0.0)]).execute()
Exemplo n.º 6
0
def send_input(n, n2, action):
    s = control.nexus().comm.get_com("grids")
    s.move_mouse(int(n), int(n2))
    s.kill()
    grids.wait_for_death(settings.DOUGLAS_TITLE)
    int_a = int(action)
    if int_a == 0:
        Playback([(["mouse", "left", "click"], 0.0)]).execute()
    elif int_a == 1:
        Playback([(["mouse", "right", "click"], 0.0)]).execute()
Exemplo n.º 7
0
 def process_command(self, proc):
     # Process the output from the command.
     RunCommand.process_command(self, proc)
     # Only reboot dragon if the command was successful and online_mode is true
     # 'pip install ...' may exit successfully even if there were connection errors.
     if proc.wait() == 0 and update:
         Playback([(["reboot", "dragon"], 0.0)]).execute()
Exemplo n.º 8
0
class MainRule(MappingRule):

    mapping = {
        # it is this section that you want to fiddle around with if you're new: mapping, extras, and defaults

        # in the next line, there are two things to observe:
        # the first is the use of parentheses and the pipe symbol (|)
        # --this lets me use either "lock dragon" or "deactivate" to trigger that command.
        # The next is the playback action, which lets me tell Dragon to simulate me speaking some words.
        '(lock Dragon | deactivate)':
        Playback([(["go", "to", "sleep"], 0.0)]),

        # Here I'm using BringApp-- this is the same as typing what goes in between the parentheses
        # into the Windows command prompt, without the quotes and commas, like:
        # explorer C:\NatLink\NatLink\MacroSystem
        # -- (which would open Windows Explorer at the specified location). Anything you can do with the command line can be done this way
        # IMPORTANT: If you don't have Dragonfly  6.6  or later, lines 40 and 46  will cause this file to crash and should be commented out
        "open natlink folder":
        BringApp("explorer", "C:\NatLink\NatLink\MacroSystem"),

        # here I'm using the Key action to press some keys -- see the documentation here: http://dragonfly.readthedocs.org/en/latest/actions.html?highlight=key#module-dragonfly.actions.action_key
        "remax":
        Key("a-space/10,r/10,a-space/10,x"),

        # here I'm chaining a bunch of different actions together to do a complex task
        "(show | open) documentation":
        BringApp(
            'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe')
        + WaitWindow(executable="chrome.exe") + Key('c-t') +
        WaitWindow(title="New Tab") +
        Text('http://dragonfly.readthedocs.org/en/latest') + Key('enter'),

        # here I'm just saying one word to trigger some other words
        "hotel":
        Text("hotels are not cheap"),

        # If you need to do more complicated tasks, or use external resources, a function might be what you need.
        # note that here, I'm using extras: "n" and "text"
        # The angle brackets <> meaning I'm using an extra, and the square brackets [] mean that I don't have to speak that word, it's optional.
        # Advice: if you use an optional extra, like I am with "text", you should set a default value  in the defaults section down below.
        # To trigger the following command, you would have to say the word "function" followed by a number between 1 and 1000.
        '[use] function <n> [<text>]':
        Function(my_function, extra={'n', 'text'}),
    }
    extras = [
        IntegerRef("n", 1, 1000),
        Dictation("text"),
        Choice("choice", {
            "alarm": "alarm",
            "custom grid": "CustomGrid",
            "element": "e"
        }),
    ]
    defaults = {
        "n": 1,
        "text": "",
    }
Exemplo n.º 9
0
def repeat_that(n):
    try:
        if len(control.nexus().history) > 0:
            p = [
                str(x) for x in " ".join(control.nexus().history[
                    len(control.nexus().history) - 1]).split()
            ]
            #             print p
            for i in range(int(n)):
                Playback([(p, 0.0)]).execute()
    except Exception:
        utilities.simple_log(False)
Exemplo n.º 10
0
class Dragon(MergeRule):

    mapping = {
        "reboot dragon": Function(reboot_dragon),
        "snooze": Playback([(["go to sleep"], 0.0)]),
        # the next two words are often misrecognized on their own
        "him": Function(do_nothing),
        "the": Function(do_nothing),
        "it's": Function(do_nothing),
        "server test": Function(test_server_functionality)
    }
    mapping.update({word: Function(do_nothing) for word in do_nothing_words})

    extras = []

    defaults = {}
Exemplo n.º 11
0
 def _repeat(utterance):
     Playback([(utterance, 0.0)]).execute()
     return False
Exemplo n.º 12
0
class MainRule(MergeRule):
    @staticmethod
    def generate_ccr_choices(nexus):
        choices = {}
        for ccr_choice in nexus.merger.global_rule_names():
            choices[ccr_choice] = ccr_choice
        return Choice("name", choices)

    @staticmethod
    def generate_sm_ccr_choices(nexus):
        choices = {}
        for ccr_choice in nexus.merger.selfmod_rule_names():
            choices[ccr_choice] = ccr_choice
        return Choice("name2", choices)

    mapping = {
        # update management
        "update caster":
        R(DependencyUpdate([pip, "install", "--upgrade", "castervoice"])),
        "update dragonfly":
        R(DependencyUpdate([pip, "install", "--upgrade", "dragonfly2"])),

        # hardware management
        "volume <volume_mode> [<n>]":
        R(Function(navigation.volume_control, extra={'n', 'volume_mode'})),
        "change monitor":
        R(Key("w-p") + Pause("100") + Function(change_monitor)),

        # window management
        'minimize':
        R(Playback([(["minimize", "window"], 0.0)])),
        'maximize':
        R(Playback([(["maximize", "window"], 0.0)])),
        "remax":
        R(Key("a-space/10,r/10,a-space/10,x")),

        # passwords

        # mouse alternatives
        "legion [<monitor>]":
        R(Function(navigation.mouse_alternates, mode="legion", nexus=_NEXUS)),
        "rainbow [<monitor>]":
        R(Function(navigation.mouse_alternates, mode="rainbow", nexus=_NEXUS)),
        "douglas [<monitor>]":
        R(Function(navigation.mouse_alternates, mode="douglas", nexus=_NEXUS)),

        # ccr de/activation
        "<enable> <name>":
        R(Function(_NEXUS.merger.global_rule_changer(), save=True)),
        "<enable> <name2>":
        R(Function(_NEXUS.merger.selfmod_rule_changer(), save=True)),
        "enable caster":
        R(Function(_NEXUS.merger.merge, time=MergeInf.RUN, name="numbers")),
        "disable caster":
        R(Function(_NEXUS.merger.ccr_off)),
    }
    extras = [
        IntegerRefST("n", 1, 50),
        Dictation("text"),
        Dictation("text2"),
        Dictation("text3"),
        Choice("enable", {
            "enable": True,
            "disable": False
        }),
        Choice("volume_mode", {
            "mute": "mute",
            "up": "up",
            "down": "down"
        }),
        generate_ccr_choices.__func__(_NEXUS),
        generate_sm_ccr_choices.__func__(_NEXUS),
        IntegerRefST("monitor", 1, 10)
    ]
    defaults = {
        "n": 1,
        "nnv": 1,
        "text": "",
        "volume_mode": "setsysvolume",
        "enable": -1
    }
class CustomStuff(MergeRule):
    pronunciation = "custom stuff"
    mapping = {
        "open new file":
            R(Key("c-n"), rdescript="Custom Navigation: Open New File"),
        "toggle tab":
            R(Key("c-tab"), rdescript="Next Tab"),
        "Ali":
            R(Key("c-a"), rdescript="Select All"),
        "back tab [<n>]":
            R(Key("s-tab"), rdescript="Previous Tab")*Repeat(extra="n"),
        "(windy | Wendy) lease [<n>]":
            R(Key("w-left"), rdescript="Window Left")*Repeat(extra="n"),
        "(windy | Wendy) ross [<n>]":
            R(Key("w-right"), rdescript="Window Right")*Repeat(extra="n"),
        "mahni lease [<n>]":
            R(Key("sw-left"), rdescript="Monitor Left")*Repeat(extra="n"),
        "manhi ross [<n>]":
            R(Key("sw-right"), rdescript="Monitor Right")*Repeat(extra="n"),
        "workace lease":
            R(Key("cw-left"), rdescript="Workspace Left"),
        "workace ross":
            R(Key("cw-right"), rdescript="Monitor Right"),
        "peach":
            R(Key("c-t"), rdescript="Open New Tab"),
        "totch":
            R(Key("c-w/20"), rdescript="Close Tab"),
        "Lexi":
            R(Key("s-home"), rdescript="Custom Navigation: Home Key"),
        "Ricksy":
            R(Key("s-end"), rdescript="Custom Navigation: End Key"),
        "snipple":
            R(Key("s-home") + Key("del/5"), rspec="snipple", rdescript="Delete to beginning of line"),
        "(sniper | snipper)":
            R(Key("s-end") + Key("del/5"), rspec="snipper", rdescript="Delete to end of line"),
        "shreep [<nnavi50>]":
            R(Key("s-up"), rspec="shreeep", rdescript="Select a line up")*
            Repeat(extra="nnavi50"),
        "shroom [<nnavi50>]":
            R(Key("s-down"), rspec="shroom", rdescript="Select a line down")*
            Repeat(extra="nnavi50"),
        "(Kate | Kite) [<nnavi50>]":
            R(Key("c-del"), rspec="clear", rdescript="Backspace")*Repeat(extra="nnavi50"),
        "trough [<nnavi50>]":
            R(Key("c-backspace"), rspec="clear", rdescript="Backspace")*
            Repeat(extra="nnavi50"),
        'duke':
            R(Function(navigation.left_click)*Repeat(2)),        
        "cram <textnv>":
            R(Function(format_text_wrapper, cap=3, space=1), rdescript="camelCase"),
        "smash <textnv>":
            R(Function(format_text_wrapper, cap=5, space=1),
              rdescript="lowercasenospaces"),
        "squash <textnv>":
            R(Function(format_text_wrapper, cap=5, space=0),
              rdescript="lowercase with spaces"),
        "scrodge [<nnavi50>]":
            R(Function(wheel_scroll_down), rdescript="Wheel Scroll"),
        "scroop [<nnavi50>]":
            R(Function(wheel_scroll_up), rdescript="Wheel Scroll"),
        'snore':
            R(Playback([(["go", "to", "sleep"], 0.0)])),

        # The following commands of been enabled via words.txt
        # If Caster gets rid of transformers, reenable these words
        # "(chiff | Jeff) [<nnavi3>]":
        #     R(Function(navigation.left_click))*Repeat(extra="nnavi3"),
        # "marco":
        #     R(Key("c-f"), rdescript="Find"),
        # "dizzle [<n>]":
        #     R(Key("c-z"), rdescript="Undo")*Repeat(extra="n"),
        # "rizzle [<n>]":
        #     R(Key("c-y"), rdescript="Redo")*Repeat(extra="n"),
        # "(windy | Wendy) Max":
        #     R(Key("w-up"), rdescript="Maximize Window"),
        # "snatch":
        #     R(Key("c-x"), rdescript="Open New Tab"),
        # "junk [<nnavi50>]":
        #     R(Key("backspace/5:%(nnavi50)d"), rspec="clear", rdescript="Backspace"),
        # "spunk [<nnavi50>]":
        #     R(Key("del/5"), rspec="deli", rdescript="Delete")*Repeat(extra="nnavi50"),
        # "fish [<nnavi50>]":
        #     R(Key("c-right"), rspec="fish", rdescript="Jump word to the right")*
        #     Repeat(extra="nnavi50"),
        # "fame [<nnavi50>]":
        #     R(Key("c-left"), rspec="fame", rdescript="Jump word to the Left")*
        #     Repeat(extra="nnavi50"),
        # "scrish [<nnavi50>]":
        #     R(Key("cs-right"), rspec="scrish", rdescript="Select word to the right")*
        #     Repeat(extra="nnavi50"),
        # "scram [<nnavi50>]":
        #     R(Key("cs-left"), rspec="scram", rdescript="Select a word to the left")*
        #     Repeat(extra="nnavi50"),

        # Deprecated
        # "tridal <textnv>":
        #     R(Function(format_text_wrapper, cap=2, space=0), rdescript="Title Case"),
        # "Champ <textnv>":
        #     R(Function(format_text_wrapper, cap=4, space=0),
        #       rdescript="Capitalize first word"),
        # "Lefty":
        #     R(Key("home"), rdescript="Custom Navigation: Home Key"),
        # "Ricky":
        #     R(Key("end"), rdescript="Custom Navigation: End Key"),
    }
    extras = [
        ShortIntegerRef("nnavi3", 1, 4),
        ShortIntegerRef("n", 1, 10),
        ShortIntegerRef("nnavi50", 1, 50),
        Dictation("textnv"),
    ]
    defaults = {"n": 1, "nnavi50": 1, "textnv": ""}
Exemplo n.º 14
0
def change_monitor():
    if settings.SETTINGS["miscellaneous"]["sikuli_enabled"]:
        Playback([(["monitor", "select"], 0.0)]).execute()
    else:
        print(
            "This command requires SikuliX to be enabled in the settings file")
Exemplo n.º 15
0
class MyRule(MappingRule):

    # It is this section that you want to edit if you're new. The mapping, extras, and defaults
    mapping = {

        # Here I'm just saying two words to trigger some other words
        "hotel info":
        Text("These types of hospitality services are not cheap."),

        # In the next line, there are two things to observe:
        # the first is the use of parentheses and the pipe symbol (|)
        # --this lets me use either "motel" or "lodging" to trigger that command.
        # The next is the playback action, which lets me tell the speech recognition engine to simulate me speaking some words.
        "(motel | lodging)":
        Playback([(["hotel", "info"], 0.0)]),

        # Here I'm using BringApp -- this is the same as typing what goes in between the parentheses
        # into the command prompt/terminal, without the quotes and commas, like:
        # Windows OS: explorer C:\NatLink\NatLink\MacroSystem
        # Could be changed changed for Linux/Mac
        # -- (which would open Windows Explorer at the specified location). Anything you can do with the command line can be done this way
        "open natlink folder":
        BringApp("explorer", r"C:\NatLink\NatLink\MacroSystem"),

        # Here I'm using the Key action to press some keys -- see the documentation here: https://dragonfly2.readthedocs.io/en/latest/actions.html?#module-dragonfly.actions.action_key
        # "a-" Everything before "-" is a keyboard modifier, "a" is for the "alt" Key.
        # "-space" reprresents the SpaceBar Key.
        # "/10" After "a-space" Slows down the keypresses by 10 ms" with a seriess of keypresses as demonstrated this may be necessary.
        # The comma "," after "a-space/10" separates keypresses in a series.
        "remax":
        Key("a-space/10,r/10,a-space/10,x"),

        # Here I'm chaining a bunch of different actions together to do a complex task
        # This is Windows OS speciffic but the path in BringApp could be changed for Linux/Mac
        "(show | open) documentation":
        BringApp(
            'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe')
        + WaitWindow(executable="chrome.exe") + Key('c-t') +
        WaitWindow(title="New Tab") +
        Text('https://dragonfly2.readthedocs.io/en/latest') + Key('enter'),

        # If you need to do more complicated tasks, or use external resources, a function might be what you need.
        # Note that here, I'm using extras: "n" and "text"
        # The angle brackets <> meaning I'm using an extra, and the square brackets [] mean that I don't have to speak that word, it's optional.
        # Advice: if you use an optional extra, like I am with "text", you should set a default value  in the defaults section down below.
        # To trigger the following command, you would have to say the word "function" followed by a number between 1 and 1000.
        '[use] function <n> [<text>]':
        Function(my_function, extra={'n', 'text'}),

        # Sometimes it's easier to have things as a list in a command as a choice that do different things.
        # That's what `<choice>` Is defined in `extras` allows you define that list. If you dictate `i choose custom grid` Then `CustomGrid` will be printed as text.
        # Items in the list are pairs. e.g `{"custom grid": "CustomGrid"}` The first item of a pair is the command "custom grid" and the second "CustomGrid" output text action.
        "i choose <choice>":
        Text("%(choice)s"),
    }

    extras = [
        IntegerRef("n", 1, 1000),
        Dictation("text"),
        Choice("choice", {
            "alarm": "alarm",
            "custom grid": "CustomGrid",
            "element": "e"
        }),
    ]
    defaults = {
        "n": 1,
        "text": "",
    }
Exemplo n.º 16
0
 def switch_mode(self, mode="command"):
     Playback([([mode, "mode", "on"], 0.0)]).execute()
     self.mode = mode
Exemplo n.º 17
0
class DragonRule(MergeRule):
    pronunciation = "dragon"

    mapping = {
        '(lock Dragon | deactivate)':
        R(Playback([(["go", "to", "sleep"], 0.0)]),
          rdescript="Dragon: Go To Sleep"),
        '(number|numbers) mode':
        R(Playback([(["numbers", "mode", "on"], 0.0)]),
          rdescript="Dragon: Number Mode"),
        'spell mode':
        R(Playback([(["spell", "mode", "on"], 0.0)]),
          rdescript="Dragon: Spell Mode"),
        'dictation mode':
        R(Playback([(["dictation", "mode", "on"], 0.0)]),
          rdescript="Dragon: Dictation Mode"),
        'normal mode':
        R(Playback([(["normal", "mode", "on"], 0.0)]),
          rdescript="Dragon: Normal Mode"),
        'command mode':
        R(Playback([(["command", "mode", "on"], 0.0)]),
          rdescript="Dragon: Normal Mode"),
        'com on':
        R(Playback([(["command", "mode", "on"], 0.0)]),
          rdescript="Dragon: Command Mode (On)"),
        'com off':
        R(Playback([(["command", "mode", "off"], 0.0)]),
          rdescript="Dragon: Command Mode (Off)"),
        'scratch':
        R(Playback([(["scratch", "that"], 0.0)]),
          rdescript="Dragon: 'Scratch That'"),
        "reboot dragon":
        R(Function(utilities.reboot),
          rdescript="Reboot Dragon Naturallyspeaking"),
        "fix dragon double":
        R(Function(fix_dragon_double, nexus=_NEXUS),
          rdescript="Fix Dragon Double Letter"),
        "left point":
        R(Playback([(["MouseGrid"], 0.1), (["four", "four"], 0.1),
                    (["click"], 0.0)]),
          rdescript="Mouse: Left Point"),
        "right point":
        R(Playback([(["MouseGrid"], 0.1), (["six", "six"], 0.1),
                    (["click"], 0.0)]),
          rdescript="Mouse: Right Point"),
        "center point":
        R(Playback([(["MouseGrid"], 0.1), (["click"], 0.0)]),
          rdescript="Mouse: Center Point"),
    }
    extras = [
        Dictation("text"),
        Dictation("mim"),
        IntegerRefST("n", 1, 1000),
    ]
    defaults = {"n": 1, "mim": ""}
Exemplo n.º 18
0
class MainRule(MergeRule):
    @staticmethod
    def generate_ccr_choices(nexus):
        choices = {}
        for ccr_choice in nexus.merger.global_rule_names():
            choices[ccr_choice] = ccr_choice
        return Choice("name", choices)

    @staticmethod
    def generate_sm_ccr_choices(nexus):
        choices = {}
        for ccr_choice in nexus.merger.selfmod_rule_names():
            choices[ccr_choice] = ccr_choice
        return Choice("name2", choices)

    mapping = {
        # Dragon NaturallySpeaking commands moved to dragon.py

        # hardware management
        "volume <volume_mode> [<n>]":
        R(Function(navigation.volume_control, extra={'n', 'volume_mode'}),
          rdescript="Volume Control"),
        "change monitor":
        R(Key("w-p") + Pause("100") + Function(change_monitor),
          rdescript="Change Monitor"),

        # window management
        'minimize':
        Playback([(["minimize", "window"], 0.0)]),
        'maximize':
        Playback([(["maximize", "window"], 0.0)]),
        "remax":
        R(Key("a-space/10,r/10,a-space/10,x"), rdescript="Force Maximize"),

        # passwords

        # mouse alternatives
        "legion [<monitor>]":
        R(Function(navigation.mouse_alternates, mode="legion", nexus=_NEXUS),
          rdescript="Activate Legion"),
        "rainbow [<monitor>]":
        R(Function(navigation.mouse_alternates, mode="rainbow", nexus=_NEXUS),
          rdescript="Activate Rainbow Grid"),
        "douglas [<monitor>]":
        R(Function(navigation.mouse_alternates, mode="douglas", nexus=_NEXUS),
          rdescript="Activate Douglas Grid"),

        # ccr de/activation
        "<enable> <name>":
        R(Function(_NEXUS.merger.global_rule_changer(), save=True),
          rdescript="Toggle CCR Module"),
        "<enable> <name2>":
        R(Function(_NEXUS.merger.selfmod_rule_changer(), save=True),
          rdescript="Toggle sm-CCR Module"),
    }
    extras = [
        IntegerRefST("n", 1, 50),
        Dictation("text"),
        Dictation("text2"),
        Dictation("text3"),
        Choice("enable", {
            "enable": True,
            "disable": False
        }),
        Choice("volume_mode", {
            "mute": "mute",
            "up": "up",
            "down": "down"
        }),
        generate_ccr_choices.__func__(_NEXUS),
        generate_sm_ccr_choices.__func__(_NEXUS),
        IntegerRefST("monitor", 1, 10)
    ]
    defaults = {
        "n": 1,
        "nnv": 1,
        "text": "",
        "volume_mode": "setsysvolume",
        "enable": -1
    }
Exemplo n.º 19
0
 def _process_recognition(self, node, extras):
     if "n" in extras:
         for i in range(0, int(extras["n"])):
             Playback(self.playback_array).execute()
     else:
         Playback(self.playback_array).execute()
Exemplo n.º 20
0
class MainRule(MappingRule):
    
    @staticmethod
    def generate_CCR_choices():
        choices = {}
        for ccr_choice in settings.get_list_of_ccr_config_files():
            choices[settings.get_ccr_config_file_pronunciation(ccr_choice)] = ccr_choice
        return Choice("ccr_mode", choices)
    
    mapping = {
    # Dragon NaturallySpeaking commands moved to dragon.py
    
    # hardware management
    "volume <volume_mode> [<n>]":   R(Function(navigation.volume_control, extra={'n', 'volume_mode'}), rdescript="Volume Control"),
    "change monitor":               R(Key("w-p") + Pause("100") + Function(change_monitor), rdescript="Change Monitor"),
    
    # window management
    'minimize':                     Playback([(["minimize", "window"], 0.0)]),
    'maximize':                     Playback([(["maximize", "window"], 0.0)]),
    "remax":                        R(Key("a-space/10,r/10,a-space/10,x"), rdescript="Force Maximize"),
        
    # passwords
    'hash password <text> <text2> <text3>':                    R(Function(password.hash_password), rdescript="Get Hash Password"),
    'get password <text> <text2> <text3>':                     R(Function(password.get_password), rdescript="Get Seed Password"),
    'get restricted password <text> <text2> <text3>':          R(Function(password.get_restricted_password), rdescript="Get Char-Restricted Password"),
    'quick pass <text> <text2> <text3>':                       R(Function(password.get_simple_password), rdescript="Get Crappy Password"),
    
    # mouse alternatives
    "legion":                       R(Function(navigation.mouse_alternates, mode="legion"), rdescript="Activate Legion"),
    "rainbow":                      R(Function(navigation.mouse_alternates, mode="rainbow"), rdescript="Activate Rainbow Grid"),
    "douglas":                      R(Function(navigation.mouse_alternates, mode="douglas"), rdescript="Activate Douglas Grid"),
    
    # pita (fuzzy string matching)
    "scan directory":               R(Function(scanner.scan_directory), rdescript="Scan Directory For PITA"),
    "rescan current":               R(Function(scanner.rescan_current_file), rdescript="Rescan Current File For PITA"),
    
    # macro recording and automation
    "record from history":          R(Function(recording.record_from_history), rdescript="Create Macro From Spoken"),
    "delete recorded macros":       R(Function(recording.delete_recorded_rules), rdescript="Delete Recorded Macros"),
    "wait sec [<n>]":               R(Pause("%(n)d00"), rdescript="Wait (Macro Recording)"),
    
    # aliasing
    "alias <text>":                 R(Function(recording.add_alias), rdescript="Create Alias Command"),
    "delete aliases":               R(Function(recording.delete_alias_rules), rdescript="Delete All Alias Commands"),
    "chain alias":                  R(Function(recording.get_chain_alias_spec), rdescript="Create CCR Alias Command"), 
    
    # miscellaneous
    "<enable_disable> <ccr_mode>":  R(Function(ccr.set_active_command), rdescript="Enable CCR Module"),
    "refresh <ccr_mode>":           R(Function(ccr.refresh_from_files), rdescript="Refresh CCR Module"), 
    "again (<n> [(times|time)] | do)":R(Function(recording.repeat_that), rdescript="Repeat Last Action"),
#     "edit settings":                R(Function(), rdescript="Edit Caster Settings"), 
    
    }
    extras = [
              IntegerRef("n", 1, 50),
              Dictation("text"),
              Dictation("text2"),
              Dictation("text3"),
              Choice("enable_disable",
                    {"enable": 1, "disable": 0
                    }),
              Choice("volume_mode",
                    {"mute": "mute", "up":"up", "down":"down"
                     }),
              generate_CCR_choices.__func__()
             ]
    defaults = {"n": 1, "nnv": 1,
               "text": "", "volume_mode": "setsysvolume",
               "enable":-1
               }
Exemplo n.º 21
0
class DragonRule(MappingRule):
    mapping = {
        '(number|numbers) mode':
        R(Playback([(["numbers", "mode", "on"], 0.0)])),
        'spell mode':
        R(Playback([(["spell", "mode", "on"], 0.0)])),
        'dictation mode':
        R(Playback([(["dictation", "mode", "on"], 0.0)])),
        'normal mode':
        R(Playback([(["normal", "mode", "on"], 0.0)])),
        '(command mode | command on | com on)':
        R(Playback([(["command", "mode", "on"], 0.0)])),
        '(command off | com off)':
        R(Playback([(["command", "mode", "off"], 0.0)])),
        "fix dragon double":
        R(Function(fix_dragon_double)),
        "left point":
        R(
            Playback([(["MouseGrid"], 0.1), (["four", "four"], 0.1),
                      (["click"], 0.0)])),
        "right point":
        R(
            Playback([(["MouseGrid"], 0.1), (["six", "six"], 0.1),
                      (["click"], 0.0)])),
        "center point":
        R(Playback([(["MouseGrid"], 0.1), (["click"], 0.0)]),
          rdescript="Mouse: Center Point"),
        "show windows":
        R(Mimic("list", "all", "windows"),
          rdescript="Dragon: emulate Dragon command for listing windows"),
        "cory <text>":
        R(Mimic("correct", extra="text") +
          WaitWindow(title="spelling window") + Mimic("choose", "one"),
          rdescript=
          "Dragon: brings up the correction menu for the phrase spoken in the command and chooses the 1st choice"
          ),
        "cory that":
        R(Mimic("correct", "that") + WaitWindow(title="spelling window") +
          Mimic("choose", "one"),
          rdescript=
          "Dragon: brings up the correction menu for the previously spoken phrase and chooses the first choice"
          ),
        "make that <text>":
        R(Mimic("scratch", "that") + Mimic(extra="text"),
          rdescript=
          "Dragon: deletes the dictation generated by the previous utterance and replaces it with what you say next"
          ),
        "scratch [<n10>]":
        R(Playback([(["scratch", "that"], 0.03)]),
          rdescript="Dragon: delete dictation from previous n utterances") *
        Repeat(extra="n10"),

        # Users may want to adjust the wait time on the next few commands
        "train word":
        R(Mimic("train", "that") + Pause("75") + Key("a-r/250, s"),
          rdescript=
          "Dragon: quickly train word when you have it selected in a Dragon friendly text field"
          ),
        "word train":
        R(Key("c-c/20") + Mimic("edit", "vocabulary") +
          Key("c-v/5, tab, down, up, a-t/50, enter/50, a-r/250, s/50, escape"),
          rdescript=
          "train word quickly once you have it selected in non-full text control application"
          ),
        "(add train | train from add word)":
        R(Key("a-a/2, enter/300, a-s"),
          rdescript="Dragon: quickly train word from the add word dialogbox"),
        "(train from vocab | cab train)":
        R(Key("a-t/50, enter/50, a-r/250, s"),
          rdescript="Dragon: quickly train word from Vocabulary Editor"),
        "(train from vocab | cab train)":
        R(Key("a-t/50, enter/50, a-r/250, s"),
          rdescript="Dragon: quickly train word from Vocabulary Editor"),
        "remove from vocab":
        R(Key("c-c/5") + Mimic("edit", "vocabulary") + Pause("20") +
          Key("c-v/10, tab, down, up/5, a-d, y, escape/30, right"),
          rdescript="Dragon: remove selected word from vocabulary"),
        "(add to vocab | vocab that)":
        R(Key("c-c/5") + Mimic("add", "word") + Pause("20") +
          Key("c-v, a-a/2, enter/300, a-s/30, right"),
          rdescript="Dragon: add selected word to vocabulary and train it"),
        "recognition history":
        R(Playback([(["view", "recognition", "history"], 0.03)]),
          rdescript="Dragon: open Dragon recognition history"),
        "peak [recognition] history":
        R(Playback([(["view", "recognition", "history"], 0.03)]) +
          Pause("300") + Key("escape"),
          rdescript="Dragon: open Dragon recognition history then close it"),
        "[dictation] sources":
        R(Mimic("manage", "dictation", "sources"),
          rdescript="Dragon: manage dictation sources"),
    }
    # see above
    extras = extras_for_whole_file()
    defaults = defaults_for_whole_file()
Exemplo n.º 22
0
def kick_right():
    kill_grids_and_wait()
    Playback([(["mouse", "right", "click"], 0.0)]).execute()
Exemplo n.º 23
0
class NavigationNon(MappingRule):
    mapping = {
        # "<direction> <time_in_seconds>":
        #     AsynchronousAction(
        #         [L(S(["cancel"], Key("%(direction)s"), consume=False))],
        #         repetitions=1000,
        #         blocking=False),
        "erase multi clipboard":
        R(Function(navigation.erase_multi_clipboard, nexus=_NEXUS),
          rdescript="Erase Multi Clipboard"),
        "find":
        R(Key("c-f"), rdescript="Find"),
        "find next [<n>]":
        R(Key("f3"), rdescript="Find Next") * Repeat(extra="n"),
        "find prior [<n>]":
        R(Key("s-f3"), rdescript="Find Prior") * Repeat(extra="n"),
        "find everywhere":
        R(Key("cs-f"), rdescript="Find Everywhere"),
        "replace":
        R(Key("c-h"), rdescript="Replace"),
        "(F to | F2)":
        R(Key("f2"), rdescript="Key: F2"),
        "(F six | F6)":
        R(Key("f6"), rdescript="Key: F6"),
        "(F nine | F9)":
        R(Key("f9"), rdescript="Key: F9"),
        "[show] context menu":
        R(Key("s-f10"), rdescript="Context Menu"),
        "squat":
        R(Mouse("left:down"), rdescript="Mouse: Left Down"),
        "bench":
        R(Mouse("left:up"), rdescript="Mouse: Left Down"),
        "kick":
        R(Playback([(["mouse", "click"], 0.0)])),
        "kick mid":
        R(Function(navigation.middle_click, nexus=_NEXUS),
          rdescript="Mouse: Middle Click"),
        "psychic":
        R(Function(navigation.right_click, nexus=_NEXUS),
          rdescript="Mouse: Right Click"),
        "(kick double|double kick)":
        R(Function(navigation.left_click, nexus=_NEXUS) * Repeat(2),
          rdescript="Mouse: Double Click"),
        "shift right click":
        R(Key("shift:down") + Mouse("right") + Key("shift:up"),
          rdescript="Mouse: Shift + Right Click"),
        "curse <direction> [<direction2>] [<nnavi500>] [<dokick>]":
        R(Function(navigation.curse), rdescript="Curse"),
        "scree <direction> [<nnavi500>]":
        R(Function(navigation.wheel_scroll), rdescript="Wheel Scroll"),
        "colic":
        R(Key("control:down") + Mouse("left") + Key("control:up"),
          rdescript="Mouse: Ctrl + Left Click"),
        # "garb [<nnavi500>]":
        #     R(Mouse("left") + Mouse("left") + Function(
        #         navigation.stoosh_keep_clipboard, nexus=_NEXUS),
        #         rdescript="Highlight @ Mouse + Copy"),
        # "drop [<nnavi500>]":
        #     R(Mouse("left") + Mouse("left") + Function(
        #         navigation.drop_keep_clipboard, nexus=_NEXUS, capitalization=0, spacing=0),
        #       rdescript="Highlight @ Mouse + Paste"),
        "sure stoosh":
        R(Key("c-c"), rdescript="Simple Copy"),
        "sure cut":
        R(Key("c-x"), rdescript="Simple Cut"),
        "sure spark":
        R(Key("c-v"), rdescript="Simple Paste"),
        "undo [<n>]":
        R(Key("c-z"), rdescript="Undo") * Repeat(extra="n"),
        "redo [<n>]":
        R(Key("c-y"), rdescript="Redo") * Repeat(extra="n"),
        "refresh":
        R(Key("c-r"), rdescript="Refresh"),
        # "maxiwin":
        #     R(Key("w-up"), rdescript="Maximize Window"),
        "move window":
        R(Key("a-space, r, a-space, m"), rdescript="Move Window"),
        "window <direction> [<direction2>]":
        R(Key("win:down, %(direction)s/15, %(direction2)s, win:up"),
          rdescript="Window adjustment"),
        # Window Management
        'minimize':
        Playback([(["minimize", "window"], 0.0)]),
        'maximize':
        Playback([(["maximize", "window"], 0.0)]),
        "remax":
        R(Key("a-space/10,r/10,a-space/10,x"), rdescript="Force Maximize"),
        "monitor (left | lease) [<n>]":
        R(Key("sw-left"), rdescript="Monitor Left") * Repeat(extra="n"),
        "monitor (right | ross) [<n>]":
        R(Key("sw-right"), rdescript="Monitor Right") * Repeat(extra="n"),
        "(next | prior) window":
        R(Key("ca-tab, enter"), rdescript="Next Window"),
        "switch (window | windows)":
        R(Key("ca-tab"), rdescript="Switch Window") * Repeat(extra="n"),
        "next tab [<n>]":
        R(Key("c-pgdown"), rdescript="Next Tab") * Repeat(extra="n"),
        "prior tab [<n>]":
        R(Key("c-pgup"), rdescript="Previous Tab") * Repeat(extra="n"),
        "close tab [<n>]":
        R(Key("c-w/20"), rdescript="Close Tab") * Repeat(extra="n"),
    }

    extras = [
        Dictation("text"),
        Dictation("mim"),
        IntegerRefST("n", 1, 50),
        IntegerRefST("nnavi500", 1, 500),
        Choice(
            "time_in_seconds", {
                "super slow": 5,
                "slow": 2,
                "normal": 0.6,
                "fast": 0.1,
                "superfast": 0.05
            }),
        navigation.get_direction_choice("direction"),
        navigation.get_direction_choice("direction2"),
        navigation.TARGET_CHOICE,
        Choice("dokick", {
            "kick": 1,
            "psychic": 2
        }),
        Choice("wm", {
            "ex": 1,
            "tie": 2
        }),
    ]
    defaults = {
        "n": 1,
        "mim": "",
        "nnavi500": 1,
        "direction2": "",
        "dokick": 0,
        "text": "",
        "wm": 2
    }
Exemplo n.º 24
0
class SikuliController(object):

    _ENABLE_GEN_RULE = Playback([(["enable", "sikuli", "custom"], 0.0)])
    _DISABLE_GEN_RULE = Playback([(["disable", "sikuli", "custom"], 0.0)])

    def __init__(self):
        self._server_proxy = None
        self._timer = None

    def launch_IDE(self):
        """
        Launches the Sikuli IDE. Has no effect on anything else.
        """
        ide_path = settings.SETTINGS["paths"]["SIKULI_IDE"]
        if ide_path == "":
            print(
                "No 'SIKULI_IDE' path is available. Did you configure it in " +
                settings.get_filename())
        else:
            Popen(["java", "-jar", ide_path])

    def bootstrap_start_server_proxy(self):
        """
        There are two parts to getting Sikuli running: the server and the
        server proxy. The server is an independent process, which needs to
        already be running before the server proxy is started. This method
        attempts to start the server proxy and then if that fails, it starts
        the server and sets a timer to retry the server proxy.
        """
        try:
            # if the server is already running, this should go off without a hitch
            self._start_server_proxy()
        except Exception:
            self._start_server()
            five_seconds = 5
            self._timer = get_current_engine().create_timer(
                self._retry_server_proxy, five_seconds)

    def _start_server(self):
        runner_path = settings.SETTINGS["paths"]["SIKULI_RUNNER"]
        if runner_path == "":
            print(
                "No 'SIKULI_RUNNER' path is available. Did you configure it in "
                + settings.get_filename())
        else:
            command = [] if settings.SETTINGS["sikuli"][
                "version"] == "1.1.3" else ["java", "-jar"]
            command.extend([
                settings.SETTINGS["paths"]["SIKULI_RUNNER"], "-r",
                settings.SETTINGS["paths"]["SIKULI_SERVER_PATH"], "--args",
                settings.SETTINGS["paths"]["SIKULI_SCRIPTS_PATH"]
            ])
            Popen(command)

    def _start_server_proxy(self):
        """
        This method will fail if the server isn't started yet.
        """
        # this will never fail:
        self._server_proxy = control.nexus().comm.get_com("sikuli")
        # this will fail if the server isn't started yet:
        self._server_proxy.list_functions()
        # success at this point:
        printer.out("Caster-Sikuli server started successfully.")
        SikuliController._ENABLE_GEN_RULE.execute()

    def _retry_server_proxy(self):
        printer.out("Attempting Caster-Sikuli connection [...]")
        try:
            self._start_server_proxy()
            if self._timer:
                self._timer.stop()
                self._timer = None
        except socket.error:
            pass
        except Exception:
            traceback.print_exc()

    def terminate_server_proxy(self):
        control.nexus().comm.coms.pop('sikuli')
        self._server_proxy.terminate()
        SikuliController._DISABLE_GEN_RULE.execute()

    def _execute(self, fname):
        try:
            fn = getattr(self._server_proxy, fname)
            fn()
        except Exception:
            utilities.simple_log()

    def generate_commands(self):
        list_of_functions = []
        if self._server_proxy is not None:
            list_of_functions = self._server_proxy.list_functions()
        mapping = {}
        for fname in list_of_functions:
            spec = " ".join(fname.split("_"))
            mapping[spec] = Function(self._execute, fname=fname)
        return mapping