class DevelopmentHelp(MappingRule): mapping = { # caster 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": R(BringApp("C:/Windows/explorer.exe", settings.SETTINGS["paths"]["BASE_PATH"].replace("/", "\\")), rdescript="Open Natlink Folder"), "refresh debug file": Function(devgen.refresh), "Agrippa <filetype> <path>": Function(grep_this), "run rule complexity test": Function(lambda: run_tests()), "run unit tests": Function(testrunner.run_tests), "run remote debugger": Function(run_remote_debugger), } extras = [ Dictation("text"), Choice("path", { "natlink": "c:/natlink/natlink", "sea": "C:/", }), Choice("filetype", { "java": "*.java", "python": "*.py", }) ] defaults = {"text": ""}
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": "", }
class DevelopmentHelp(MappingRule): mapping = { # caster development tools "(show | open) <url> documentation": Function(launch_url), "open natlink folder": R(BringApp("C:/Windows/explorer.exe", settings.SETTINGS["paths"]["BASE_PATH"].replace("/", "\\")), rdescript="Open Natlink Folder"), "refresh debug file": Function(devgen.refresh), "Agrippa <filetype> <path>": Function(grep_this), "run rule complexity test": Function(lambda: run_tests()), "run unit tests": Function(testrunner.run_tests), "run remote debugger": Function(run_remote_debugger), } extras = [ Dictation("text"), Choice("path", { "natlink": "c:/natlink/natlink", "sea": "C:/", }), Choice("filetype", { "java": "*.java", "python": "*.py", }), Choice( "url", { "caster": "https://caster.readthedocs.io/en/latest/", "dragonfly": "https://dragonfly2.readthedocs.io/en/latest/", }), ] defaults = {"text": ""}
def startTrackingPrograms(): BringApp(r'C:\Users\loves\programming\humanInterface\openeViacam.bat').execute() BringApp(r'C:\Users\loves\programming\humanInterface\openPrecisionGazeMouse.bat').execute()
from dragonfly import BringApp, StartApp #StartApp(r"c:\Windows\system32\notepad.exe").execute() #StartApp(r"%SystemRoot%\system32\notepad.exe").execute() # #BringApp(r"c:\Windows\system32\notepad.exe").execute() BringApp("winword").execute()
def bring_test(): print(settings.SETTINGS["paths"]["BASE_PATH"].replace("/", "\\")) try: BringApp("explorer", settings.SETTINGS["paths"]["BASE_PATH"]).execute() except Exception: utilities.simple_log()
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": "", }
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}
def bringDynamic(text): print text BringApp(text + "").execute()