Ejemplo n.º 1
0
 def _process_recognition(self, node, extras):
     title = str(extras["text"])
     action = FocusWindow(title=title)
     try:
         action.execute()
     except ActionError:
         self._log.warning("No window with that name found.")
Ejemplo n.º 2
0
 def _process_recognition(self, node, extras):
     title = str(extras["text"])
     action = FocusWindow(title=title)
     try:
         action.execute()
     except ActionError:
         self._log.warning("No window with that name found.")
Ejemplo n.º 3
0
 def _execute(self, data=None):
     self._log.debug("Bringing app: %r" % (self._args,))
     target = self._args[0].lower()
     focus_action = FocusWindow(executable=target)
     # Attempt to focus on an existing window.
     if not focus_action.execute():
         # Failed to focus on an existing window, so start
         #  the application.
         StartApp._execute(self, data)
Ejemplo n.º 4
0
def reload_natlink():
    """Reloads Natlink and custom Python modules."""
    win = Window.get_foreground()
    FocusWindow(executable="natspeak",
                title="Messages from Python Macros").execute()
    Pause("10").execute()
    Key("a-f, r").execute()
    Pause("10").execute()
    win.set_foreground()
Ejemplo n.º 5
0
def launch(hmc_type, data=None):
    from dragonfly import (WaitWindow, FocusWindow, Key)
    instructions = _get_instructions(hmc_type)
    if data is not None:  # and callback!=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()
Ejemplo n.º 6
0
def show_natlink_messages_window(duration=3,
                                 msg="show_natlink_messages_window"):
    """
        bring the natlink messages window to focus/front to see what is being printed
        """
    sound.play(sound.SND_MESSAGE)
    FocusWindow("natspeak", "Messages from Python Macros").execute()
    print(msg)
    if duration > 0:
        time.sleep(duration)
        Key("alt:down, tab:down/5, alt:up").execute()
Ejemplo n.º 7
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.º 8
0
def closeProgram(name):
    (FocusWindow(title=name) + WaitWindow(title=name) + Key('a-f4')).execute()
Ejemplo n.º 9
0
class StaticRule(MappingRule):

    mapping = {
        config.lang.reload_natlink:
        FocusWindow("natspeak", "Messages from Python Macros") + Key("a-f, r"),
    }
Ejemplo n.º 10
0
grammar = Grammar("global")


def snore(**kw):
    natlink.setMicState('sleeping')


example_rule = MappingRule(
    name="global",
    mapping={
        'scratch': Mimic('scratch', 'that'),
        'Pick <n>': Key('down/5:%(n)d, enter'),
        'Pick Minus <n>': Key('up/5:%(n)d, enter'),
        'swap': Key('w-tab/5'),
        '<n> swap': Key('w-tab/5:%(n)d'),
        'swap <text>': FocusWindow(title='%(text)s'),
        'win left': Key('w-left'),
        'win right': Key('w-right'),
        'desk <n>': Key('w-%(n)d'),
        'snore': Function(snore),
        'Show task [manager]': Key('cs-escape'),

        #
        # Words and phrases
        'import clarus': Text('import brighttrac2 as clarus'),
    },
    extras=[
        Dictation("text"),
        IntegerRef("n", 1, 100),
    ],
)
Ejemplo n.º 11
0
class StaticRule(MappingRule):

    mapping = {
        config.lang.reload_natlink:
        FocusWindow("natspeak", "Messages from NatLink") + Key("a-r"),
    }
Ejemplo n.º 12
0
def show_natlink_status():
    FocusWindow(executable="natspeak", title="Messages from NatLink").execute()
Ejemplo n.º 13
0
def blitz_natlink_status():
    win = Window.get_foreground()
    FocusWindow(executable="natspeak", title="Messages from NatLink").execute()
    Pause("100").execute()
    win.set_foreground()
Ejemplo n.º 14
0
class DevRule(MappingRule):

    mapping = {
        # development tools
        "(show | open) documentation":
        BringApp(settings.SETTINGS["paths"]["DEFAULT_BROWSER_PATH"]) +
        WaitWindow(executable=settings.get_default_browser_executable()) +
        Key('c-t') + WaitWindow(title="New Tab") +
        Text('http://dragonfly.readthedocs.org/en/latest') + Key('enter'),
        "open natlink folder":
        Function(bring_test) + FocusWindow("explorer"),
        "reserved word <text>":
        Key("dquote,dquote,left") + Text("%(text)s") +
        Key("right, colon, tab/5:5") + Text("Text(\"%(text)s\"),"),
        "refresh ccr directory":
        Function(ccr.refresh_from_files
                 ),  # will need to disable and reenable language
        "Agrippa <filetype> <path>":
        Function(grep_this),

        # experimental/incomplete commands
        "zone test":
        R(Text("a") + Text("b")),
        "experiment <text>":
        Function(experiment),
        #
        #     "dredge [<id> <text>]":         Function(dredge),
        "close last tag":
        ContextSeeker([
            L(S(["cancel"], None),
              S(["html spoken"], close_last_spoken, use_spoken=True),
              S(["span", "div"], close_last_rspec, use_rspec=True))
        ]),
        "html":
        R(Text("<html>"), rspec="html spoken"),
        "divider":
        R(Text("<div>"), rspec="div"),
        "span":
        R(Text("<span>"), rspec="span"),
        "backward seeker [<text>]":
        ContextSeeker([
            L(S(["ashes"], Text("ashes1 [%(text)s] ")),
              S(["bravery"], Text("bravery1 [%(text)s] "))),
            L(S(["ashes"], Text("ashes2 [%(text)s] ")),
              S(["bravery"], Text("bravery2 [%(text)s] ")))
        ]),
        "forward seeker [<text>]":
        ContextSeeker(forward=[
            L(S(["ashes"], Text("ashes1 [%(text)s] ")),
              S(["bravery"], Text("bravery1 [%(text)s] "))),
            L(S(["ashes"], Text("ashes2 [%(text)s] ")),
              S(["bravery"], Text("bravery2 [%(text)s] ")))
        ]),
        "never-ending":
        AsynchronousAction([
            L(S(["ashes", "charcoal"], print_time, None),
              S(["bravery"], Text, "bravery1"))
        ],
                           time_in_seconds=0.2,
                           repetitions=20,
                           finisher=Text("finisher successful")),
        "ashes":
        RegisteredAction(Text("ashes fall "), rspec="ashes"),
        "bravery":
        RegisteredAction(Text("bravery is weak "), rspec="bravery"),
        "charcoal boy <text> [<n>]":
        R(Text("charcoal is dirty %(text)s"), rspec="charcoal"),
        "test confirm action":
        ConfirmAction(Key("a"), rdescript="Confirm Action Test"),
        "convert node <n>":
        R(Key("cs-right, cs-right/5:%(n)d, cs-right, c-x, c-v, comma") +
          Text("Text()") + Key("left, c-v"),
          rdescript="Convert Node"),
        "text action":
        R(Text("Text()") + Key("left"), rdescript="Node 2"),
        "long conversion <text>":
        R(Key("c-x") + Text("\"%(text)s\", Text(") + Key("c-v, rparen"),
          rdescript="Node 3"),
    }
    extras = [
        Dictation("text"),
        Dictation("textnv"),
        IntegerRef("n", 1, 5),
        Choice("id", {
            "R": 1,
            "M": 2,
        }),
        Choice("path", {
            "natlink": "c:/natlink/natlink",
            "sea": "C:/",
        }),
        Choice("filetype", {
            "java": "*.java",
            "python": "*.py",
        }),
    ]
    defaults = {"text": "", "id": None}