class EclipseCCR(MergeRule): pronunciation = "eclipse jump" mapping = { #Line Ops "configure": R(Paste(ec_con.analysis_chars) + Key("left:2/5, c-f/20, backslash, rbracket, enter") + Function(ec_con.analyze_for_configure)), "jump in [<n>]": R(Key("c-f, a-o") + Paste(r"[\(\[\{\<]") + Function(ec_con.regex_on) + Key("enter:%(n)d/5, escape, right")), "jump out [<n>]": R(Key("c-f, a-o") + Paste(r"[\)\] \}\>]") + Function(ec_con.regex_on) + Key("enter:%(n)d/5, escape, right")), "jump back [<n>]": R(Key("c-f/5, a-b") + Paste(r"[\)\]\}\>]") + Function(ec_con.regex_on) + Key("enter:%(n)d/5, escape, left")), "[go to] line <n>": R(Key("c-l") + Pause("50") + Text("%(n)d") + Key("enter") + Pause("50")), "shackle <n> [<back>]": R(Key("c-l") + Key("right, cs-left") + Function(ec_con.lines_relative)), } extras = [ Dictation("text"), IntegerRefST("n", 1, 1000), Boolean("back"), ] defaults = {"n": 1, "back": False}
def connect_cisco(): StartApp( R"C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpnui.exe" ).execute() Pause("100").execute() Mouse("(0.85, 0.5), left").execute() Pause("100").execute() Text(in_pass).execute() Key('enter').execute()
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()
def connect_pre(): StartApp(R"C:\Program Files (x86)\Pritunl\pritunl.exe").execute() Pause("500").execute() Mouse("(0.92, 0.1), left").execute() Pause('100').execute() Mouse("(0.92, 0.1), left").execute() Pause('400').execute() Text(sand_pass).execute() Pause('50').execute() Mouse("(0.75, 0.1), left").execute()
class CustomVSCode(MergeRule): pronunciation = "custom sublime commands" mapping = { # my custom overrides "save file as": R(Key("cs-s"), rdescript="Sublime: Save As"), "grab it": R(Key("c-d"), rdescript="Sublime: Ctrl + d"), "skip it": R(Key("c-k,c-d"), rdescript="Sublime: Ctrl + d, k"), "uppercase": R(Key("csa-u"), rdescript="Sublime: uppercase"), "lowercase": R(Key("csa-l"), rdescript="Sublime: uppercase"), "cue jeep": R(Key("a-up"), rdescript="Sublime: uppercase"), "cue doom": R(Key("a-down"), rdescript="Sublime: uppercase"), "execute": R(Key("s-enter"), rdescript="Sublime: Ctrl + b"), "[go to] group [<n2>]": R(Key("c-%(n2)s"), rdescript="Sublime: Go to Group #"), "spring <n>": R(Key("c-g") + Pause("10") + Text("%(n)s") + Key("enter"), rdescript="Sublime: Go to Line #"), "crew [<text>]": R(Key("c-i") + Pause("10") + Text("%(text)s") + Pause("10") + Key("enter") + Key("escape"), rdescript="Sublime: Get Next"), "trail [<text>]": R(Key("c-u") + Pause("10") + Text("%(text)s") + Pause("10") + Key("enter") + Key("escape"), rdescript="Sublime: Get Next"), "expand|fill quotes": R(Key("cs-space"), rdescript="Atom: Expand Selection to Quotes"), # SymbolSpecs.FUNCTION: R(Text("fu\\") + Key("tab"), rdescript="CustomSublime: Function"), # SymbolSpecs.IF: R(Text("if\\") + Key("tab"), rdescript="ColdFusion: If"), # my custom overrides "double quotes": R(Key("dquote"), rdescript="Quotation Marks"), "Quach it": R(Key("apostrophe"), rdescript="Thin Quotation Marks"), "(cellaring | sell rang) <n> <n3>": R( Key("c-g") + Pause("5") + Text("%(n)s") + Key("enter") + Pause("5") + Key("c-k") + Key("c-space") + Pause("5") + Key("c-g") + Pause("10") + Text("%(n3)s") + Key("enter") + Key("end") + Key("c-k") + Key("c-a")), } extras = [ Dictation("text"), Dictation("mim"), IntegerRefST("n", 1, 1000), IntegerRefST("n2", 1, 9), IntegerRefST("n3", 1, 999), ] defaults = {"n": 1, "mim": "", "text": ""}
class fmanRule(MergeRule): pronunciation = "F man" mapping = { "select all": R(Key("c-a")), "copy": R(Key("f5")), "deselect": R(Key("c-d")), "edit": R(Key("f4")), "end": R(Key("end")), "explorer": R(Key("f10")), "go <fav>": R(Key("c-0") + Pause("15") + Text("%(fav)s") + Key("enter")), "go see": R(Key("c-p") + Pause("15") + Text("c") + Key("enter")), "go external": R(Key("c-p") + Pause("15") + Text("e") + Key("enter")), "go to": R(Key("c-p")), "move": R(Key("f6")), "new file": R(Key("s-f4")), "new folder": R(Key("f7")), "open left": R(Key("c-left")), "open right": R(Key("c-right")), "properties": R(Key("a-enter")), "refresh": R(Key("c-r")), "rename": R(Key("s-f6")), "search": R(Key("cs-f")), "(set | add) favourite": R(Key("s-f")), "show favourites": R(Key("c-0")), "(show | hide) hidden": R(Key("c-dot")), "sort [by] name": R(Key("c-f1")), "sort [by] size": R(Key("c-f2")), "sort [by] (modified | date)": R(Key("c-f3")), "stoosh path": R(Key("f11")), "terminal": R(Key("f9")), "command pallette": R(Key("cs-p")), } extras = [ IntegerRefST("num", 1, 4), Choice( "fav", { "advent": "adv", "(docks | documents)": "docs", "(downs | download)": "downs", "git caster": "gcast", "mike": "mike", "user caster": "ucast", "uni [work]": "uni", }), ] defaults = { "num": 1, }
class CustomVSCode(MergeRule): pronunciation = "custom visual studio code" mapping = { "save file as": R(Key("cs-s"), rdescript="VS Code: Save As"), "uppercase": R(Key("csa-u"), rdescript="VS Code: uppercase"), "lowercase": R(Key("csa-l"), rdescript="VS Code: lowercase"), "execute": R(Key("s-enter"), rdescript="VS Code: Ctrl + b"), "[go to] group [<n2>]": R(Key("c-%(n2)s"), rdescript="VS Code: Go to Group #"), "spring <n>": R(Key("c-g") + Pause("10") + Text("%(n)s") + Key("enter"), rdescript="VS Code: Go to Line #"), "crew [<text>]": R(Key("c-f") + Pause("10") + Text("%(text)s") + Pause("10") + Key("escape"), rdescript="VS Code: Get Next"), "trail [<text>]": R(Key("c-f") + Pause("10") + Text("%(text)s") + Pause("10") + Key("s-enter") + Key("escape"), rdescript="VS Code: Get Next"), "expand|fill quotes": R(Key("cs-space"), rdescript="VS Code: Expand Selection to Quotes"), "(cellaring | sell rang) <n> <n3>": R( Key("c-g") + Pause("5") + Text("%(n)s") + Key("enter") + Pause("5") + Key("c-k") + Key("c-b") + Pause("5") + Key("c-g") + Pause("10") + Text("%(n3)s") + Key("enter") + Key("end") + Key("c-k") + Key("c-k")), # The following commands of been enabled via words.txt # If Caster gets rid of transformers, reenable these words # "grab it": # R(Key("c-d"), rdescript="VS Code: Ctrl + d"), # "skip it": # R(Key("c-k,c-d"), rdescript="VS Code: Ctrl + d, k"), # "cue jeep": # R(Key("a-up"), rdescript="VS Code: uppercase"), # "cue doom": # R(Key("a-down"), rdescript="VS Code: uppercase"), } extras = [ Dictation("text"), Dictation("mim"), ShortIntegerRef("n", 1, 1000), ShortIntegerRef("n2", 1, 9), ShortIntegerRef("n3", 1, 999), ] defaults = {"n": 1, "mim": "", "text": ""}
def paste_string_without_altering_clipboard(content, cb_timeout=0.200, pause_time="1", key_override=None): '''Paste content from temporary clipboard buffer. Args: content (str): content to insert into clipboard buffer. cb_timeout (int, optional): timeout monitoring for clipboard change - Windows OS increments clipboard contents, other OS's comparing clipboard contents pause_time (str, optional): Keypress delay. Defaults to 1. - Allows foreground window to process key events key_override (str, optional): Override platform paste key spec. Defaults to None. - Allows non-standard key specs to invoke paste action Returns bool: True - indicates success False - indicates clipboard error ''' if key_override is None: _default_paste_spec = "w-v/20" if sys.platform == "darwin" else "c-v/20" else: _default_paste_spec = key_override cb = Clipboard(from_system=True) try: with cb.synchronized_changes(cb_timeout): Clipboard.set_system_text(content) Key(_default_paste_spec, use_hardware=True).execute() Pause(pause_time).execute() except Exception as e: print(e) return False cb.copy_to_system() return True
def book_number(number): Key("c-k,c-w").execute() Pause('30').execute() Key("home").execute() stroke = "{}{}".format('down:',number-1) Key(stroke).execute() Key('enter').execute()
def focus_mousegrid(gridtitle): ''' Loops over active windows for MouseGrid window titles. Issue #171 When MouseGrid window titles found focuses MouseGrid overly. ''' if sys.platform.startswith('win'): # May not be needed for Linux/Mac OS - testing required try: for i in range(9): matches = Window.get_matching_windows(title=gridtitle, executable="python") if not matches: Pause("50").execute() else: break if matches: for handle in matches: handle.set_foreground() break else: printer.out( "`Title: `{}` no matching windows found".format(gridtitle)) except Exception as e: printer.out("Error focusing MouseGrid: {}".format(e)) else: pass
def read_selected_without_altering_clipboard(same_is_okay=False, pause_time="0"): '''Returns a tuple: (0, "text from system") - indicates success (1, None) - indicates no change (2, None) - indicates clipboard error ''' time.sleep(settings.SETTINGS["miscellaneous"]["keypress_wait"] / 1000.) # time for previous keypress to execute cb = Clipboard(from_system=True) temporary = None prior_content = None try: prior_content = Clipboard.get_system_text() Clipboard.set_system_text("") Key("c-c").execute() Pause(pause_time).execute() time.sleep(settings.SETTINGS["miscellaneous"]["keypress_wait"] / 1000.) # time for keypress to execute temporary = Clipboard.get_system_text() cb.copy_to_system() except Exception: utilities.simple_log(False) return 2, None if prior_content == temporary and not same_is_okay: return 1, None return 0, temporary
class HardwareRule(MappingRule): mapping = { # Windows 10 changes volume by increments 2 "volume <volume_mode> [<n_volume>]": R(Key("%(volume_mode)s") * Repeat(extra="n_volume")), "media <multimedia_control> [<n_media>]": R(Key("%(multimedia_control)s") * Repeat(extra="n_media")), "change monitor": R(Key("w-p") + Pause("100") + Function(change_monitor)) } extras = [ IntegerRefST("n_media", 1, 15), IntegerRefST("n_volume", 1, 50), Choice("multimedia_control", { "next": "tracknext", "back": "trackprev", "play|pause": "playpause", }), Choice("volume_mode", { "mute|unmute": "volumemute", "up": "volumeup", "down": "volumedown", }) ] defaults = { "n_volume": 1, "n_media": 1, "volume_mode": "setsysvolume", }
def select(n=None): if n > 1: for i in range(0, n): Key("x/5,down").execute() Pause("5").execute() else: Key("x").execute()
def ACP(command, label=None): """Utilize the Palette UI to execute commands.""" if not label: label = "Atom: Unlabeled Palette Command: " + command return R(Key("cs-p") + Pause(str(atom_palette_wait)) + Text(command) + Key("enter"), rdescript=label)
def paste_string_without_altering_clipboard(content, pause_time="1"): ''' True - indicates success False - indicates clipboard error ''' time.sleep(settings.SETTINGS["miscellaneous"]["keypress_wait"] / 1000.) # time for previous keypress to execute cb = Clipboard(from_system=True) max_tries = 20 for i in range(0, max_tries): failure = False try: Clipboard.set_system_text(unicode(content)) Pause(pause_time).execute() Key("c-v").execute() time.sleep(settings.SETTINGS["miscellaneous"]["keypress_wait"] / 1000.) # time for keypress to execute cb.copy_to_system() except Exception: print("Clipboard Write Attempts " + str(i)) # Debugging failure = True utilities.simple_log(False) if i is max_tries: return False if not failure: break return True
def execute(self): for tup in self.recorded: if type(tup[1]) is list: for action in tup[1]: action.execute() else: tup[1].execute(tup[2]) Pause("3").execute()
class Roar(MappingRule): pronunciation = "roar" mapping = { "roar": R( Key("c-a") + Key("c-c") + Key("a-f4") + Key("tab") + Key("enter") + Pause("100") + Key("c-v")), }
class fmanRule(MergeRule): pronunciation = "F man" mapping = { "copy": R(Key("f5")), "deselect": R(Key("c-d")), "edit": R(Key("f4")), "explorer": R(Key("f10")), # Set these yourself and add them to the Choice at the bottom # Requires the favourites plug-in "go <fav>": R(Key("c-0") + Pause("15") + Text("%(fav)s") + Key("enter")), "go see": R(Key("c-p") + Pause("15") + Text("c") + Key("enter")), "go to": R(Key("c-p")), "move": R(Key("f6")), "new file": R(Key("s-f4")), "new folder": R(Key("f7")), "open left": R(Key("c-left")), "open right": R(Key("c-right")), "properties": R(Key("a-enter")), "refresh": R(Key("c-r")), "rename": R(Key("s-f6")), "search": R(Key("cs-f")), "set favourite": R(Key("s-f")), "show favourites": R(Key("c-0")), "(show | hide) hidden": R(Key("c-dot")), "sort [by] name": R(Key("c-f1")), "sort [by] size": R(Key("c-f2")), "sort [by] (modified | date)": R(Key("c-f3")), "(stoosh | copy) path": R(Key("f11")), "terminal": R(Key("f9")), "command pallette": R(Key("cs-p")), } extras = [ IntegerRefST("num", 1, 4), Choice("fav", { "example favourite": "ef", }), ] defaults = { "num": 1, }
def _select_and_cut_text(wordCount): """Selects wordCount number of words to the left of the cursor and cuts them out of the text. Returns the text from the system clip board. """ clipboard = Clipboard() clipboard.set_system_text('') try: # Try selecting n number of words. Key('ctrl:down, shift:down').execute() Key('left:%s' % wordCount).execute() Key('shift:up').execute() finally: # It is important to make sure that the buttons are released. # Otherwise you get stuck in an unpleasant situation. Key('shift:up, ctrl:up').execute() Pause("10").execute() Key('c-x').execute() # Cut out the selected words. Pause("20").execute() return clipboard.get_system_text()
class FirefoxRule(MergeRule): pronunciation = "fire fox" mapping = { "(new tab|neuer Tab) [<n>]": R(Key("c-t")) * Repeat(extra="n"), "reopen tab [<n>]": R(Key("cs-t")) * Repeat(extra="n"), "show history": R(Key("c-h")), "show downloads": R(Key("c-j")), "show bookmarks": R(Key("c-b")), "[add] bookmark": R(Key("c-d")), "cancel bookmark": # Call this after "[add] bookmark" if you want to cancel R(Key("a-b")), "delete bookmark": # Call if you are on a page you have bookmarked before R(Key("c-d") + Pause("200") + Key("a-e")), "full screen": R(Key("f11")), "zoom in [<n>]": R(Key("c-plus/20")) * Repeat(extra="n"), "zoom out [<n>]": R(Key("c-minus/20")) * Repeat(extra="n"), "(leiste | address bar)": R(Key("c-l")), # the following commands requires the vim vixen extension "(scroll down | runter) [<n>]": R(Key("c-f")) * Repeat(extra="n"), "(scroll down | runter) half [<n>]": R(Key("c-d")) * Repeat(extra="n"), "(scroll up | hoeher) [<n>]": R(Key("c-b")) * Repeat(extra="n"), "(scroll up | hoeher) half [<n>]": R(Key("c-u")) * Repeat(extra="n"), "scroll top": R(Key("g") + Key("g")), "scroll bottom": R(Key("G")), "reload": R(Key("r")), "toggle pin": R(Key("z") + Key("p")), "(loesche pin | delete pin)": R(Key("!") + Key("d")), "(history back|zurueck) [<n>]": R(Key("H")) * Repeat(extra="n"), "(history forward|vorwaerts) [<n>]": R(Key("L")) * Repeat(extra="n"), "parent [<n>]": R(Key("g") + Key("u")) * Repeat(extra="n"), "root": R(Key("g") + Key("U")), "link": # opens in new tab R(Key("F")), "link here": R(Key("f")), "mark <letter>": R(Key("m") + Text("%(letter)s")), "jump <letter>": R(Key("'") + Text("%(letter)s")), "focus input": R(Text("gi")), "copy url": # copy URL in current tab R(Text("y")), "clipboard tab": # open clipboard's URL in current tab R(Text("p")), "clipboard new tab": # open clipboard's URL in new tab R(Text("P")), "toggle": # enables / disables add on R(Key("s-escape")), # from nav: next / prior / close tab } extras = [ IntegerRefST("n", 1, 100), alphanumeric.get_alphabet_choice("letter"), ] defaults = {"n": 1}
class RStudioRule(MergeRule): pronunciation = "are studio" mapping = { "new file": R(Key("cs-n"), rdescript="RStudio: New File"), "open file": R(Key("c-o"), rdescript="RStudio: Open File"), "open recent project": R(Key("a-f, j"), rdescript="RStudio: Open Recent Project"), "open project": R(Key("a-f, n, enter"), rdescript="RStudio: Open Project"), "save all": R(Key("ac-s"), rdescript="RStudio: Save All"), "select all": R(Key("c-a"), rdescript="RStudio: Select All"), "find": R(Key("c-f"), rdescript="RStudio: Find"), "[go to] line <n>": R(Key("as-g") + Pause("10") + Text("%(n)s") + Key("enter"), rdescript="RStudio: Go to Line #"), "focus console": R(Key("c-2"), rdescript="RStudio: Focus Console"), "focus main": R(Key("c-1"), rdescript="RStudio: Focus Main"), "next tab": R(Key("c-f12"), rdescript="RStudio: Next Tab"), "first tab": R(Key("cs-f11"), rdescript="RStudio: First Tab"), "previous tab": R(Key("c-f11"), rdescript="RStudio: Previous Tab"), "last tab": R(Key("cs-f12"), rdescript="RStudio: Last Tab"), "close tab": R(Key("c-w"), rdescript="RStudio: Close Tab"), "run line": R(Key("c-enter"), rdescript="RStudio: Run Line"), "run document": R(Key("ac-r"), rdescript="RStudio: Run Document"), "comment (line | selected)": R(Key("cs-c"), rdescript="RStudio: Comment Line"), "next plot": R(Key("ac-f12"), rdescript="RStudio: Next Plot"), "previous plot": R(Key("ac-f11"), rdescript="RStudio: Previous Plot"), } extras = [ IntegerRefST("n", 1, 10000), ] defaults = {}
class SSMSRule(MergeRule): pronunciation = "custom sequel server management studio" mapping = { # There doesn't seem to be a hotkey for sequential tab navigation in SSMS, but something is better than nothing... "next tab [<n>]": R(Key("c-tab"), rdescript="SSMS: Next Tab")*Repeat(extra="n"), "prior tab [<n>]": R(Key("cs-tab"), rdescript="SSMS: Previous Tab")*Repeat(extra="n"), "close tab [<n>]": R(Key("c-f4/20"), rdescript="SSMS: Close Tab")*Repeat(extra="n"), "go to line": R(Key("c-g"), rdescript="SSMS: Go To Line"), "[go to] line <n>": R(Key("c-g") + Pause("10") + Text("%(n)s") + Key("enter"), rdescript="SSMS: Go to Line #"), "comment line": R(Key("c-k, c-c"), rdescript="SSMS: Comment Selection"), "comment block": R(Key("c-k, c-c"), rdescript="SSMS: Comment Block"), "(un | on) comment line": R(Key("c-k/50, c-u"), rdescript="SSMS: Uncomment Selection"), "(un | on) comment block": R(Key("c-k/50, c-u"), rdescript="SSMS: Uncomment Block"), "[toggle] full screen": R(Key("sa-enter"), rdescript="SSMS: Fullscreen"), "(set | toggle) bookmark": R(Key("c-k, c-k"), rdescript="SSMS: Toggle Bookmark"), "next bookmark": R(Key("c-k, c-n"), rdescript="SSMS: Next Bookmark"), "prior bookmark": R(Key("c-k, c-p"), rdescript="SSMS: Previous Bookmark"), "[toggle] breakpoint": R(Key("f9"), rdescript="SSMS: Breakpoint"), "step over [<n>]": R(Key("f10/50")*Repeat(extra="n"), rdescript="SSMS: Step Over"), "step into": R(Key("f11"), rdescript="SSMS: Step Into"), "step out [of]": R(Key("s-f11"), rdescript="SSMS: Step Out"), "resume": R(Key("f5"), rdescript="SSMS: Resume"), "execute": R(Key("f5"), rdescript="SQL: Count"), "switch focus [<n>]": R(Key("f6"), rdescript="SQL: Switch Focus")*Repeat(extra="n"), "back focus [<n>]": R(Key("s-f6"), rdescript="SQL: Back Focus")*Repeat(extra="n"), } extras = [ Dictation("text"), Dictation("mim"), IntegerRefST("n", 1, 1000), ] defaults = {"n": 1, "mim": ""}
def _execute_events(self, repeat): if platform.release() >= "8": # Work around security restrictions in Windows 8. # Credit: https://autohotkey.com/board/topic/84771-alttab-mapping-isnt-working-anymore-in-windows-8/ os.startfile("C:/Users/Default/AppData/Roaming/Microsoft/Internet Explorer/Quick Launch/Window Switcher.lnk") Pause("10").execute() if platform.release() == "8": Key("tab:%d/10, enter" % (repeat - 1)).execute() else: Key("right:%d/10, enter" % repeat).execute() else: Key("alt:down, tab:%d/10, alt:up" % repeat).execute()
class FlashDevelopRule(MappingRule): mapping = { "prior tab [<n>]": R(Key("c-pgup")) * Repeat(extra="n"), "next tab [<n>]": R(Key("c-pgdown")) * Repeat(extra="n"), "open resource": R(Key("c-r")), "jump to source": R(Key("f4")), "jump away": R(Key("s-f4")), "step over [<n>]": R(Key("f10") * Repeat(extra="n")), "step into": R(Key("f11")), "step out [of]": R(Key("s-f11")), "resume": R(Key("a-d, c")), "terminate": R(Key("s-f5")), "find everywhere": R(Key("cs-f")), "refractor symbol": R(Key("a-r, r")), "symbol next [<n>]": R(Key("f3")) * Repeat(extra="n"), "symbol prior [<n>]": R(Key("s-f3")) * Repeat(extra="n"), "format code": R(Key("cs-2")), "comment line": R(Key("c-q")), "clean it": R(Key("s-f8")), "build it": R(Key("f8")), "(debug | run) last": R(Key("f5")), "split view horizontal": R(Key("cs-enter")), "auto complete": R(Key("cs-1")), "[go to] line <n>": R(Key("c-g") + Pause("50") + Text("%(n)d") + Key("enter")), } extras = [ Dictation("text"), Dictation("mim"), ShortIntegerRef("n", 1, 1000), ] defaults = {"n": 1, "mim": ""}
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'), ]
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}
class RStudioRule(MergeRule): pronunciation = "are studio" mapping = { "new file": R(Key("cs-n"), rdescript="RStudio: New File"), "open file": R(Key("c-o"), rdescript="RStudio: Open File"), "save all": R(Key("ac-s"), rdescript="RStudio: Save All"), "select all": R(Key("c-a"), rdescript="RStudio: Select All"), "find": R(Key("c-f"), rdescript="RStudio: Find"), "[go to] line <n>": R(Key("as-g") + Pause("10") + Text("%(n)s") + Key("enter"), rdescript="RStudio: Go to Line #"), "focus console": R(Key("c-2"), rdescript="RStudio: Focus Console"), "focus main": R(Key("c-1"), rdescript="RStudio: Focus Main"), "next pane": R(Key("c-f12"), rdescript="RStudio: Next pane"), "first pane": R(Key("cs-f11"), rdescript="RStudio: First pane"), "previous pane": R(Key("c-f11"), rdescript="RStudio: Previous pane"), "last pane": R(Key("cs-f12"), rdescript="RStudio: Last pane"), "close pane": R(Key("c-w"), rdescript="RStudio: Close pane"), "run (line | that)": R(Key("c-enter"), rdescript="RStudio: Run Line"), "run document": R(Key("ac-r"), rdescript="RStudio: Run Document"), "comment (line | selected)": R(Key("cs-c"), rdescript="RStudio: Comment Line"), "knit (document | file)": R(Key("cs-k")), "next plot": R(Key("ac-f12"), rdescript="RStudio: Next Plot"), "previous plot": R(Key("ac-f11"), rdescript="RStudio: Previous Plot"), "help": R(Key("c-c, c-2, question, c-v, enter, c-1")), } extras = [ IntegerRefST("n", 1, 10000), ] defaults = {}
def _process_recognition(self, node, extras): sequence = extras["sequence"] # A sequence of actions. nested_repetitions = extras["nested_repetitions"] terminal_command = extras["terminal_command"] final_command = extras["final_command"] for action in sequence: action.execute() Pause("5").execute() if nested_repetitions: nested_repetitions.execute() if terminal_command: terminal_command.execute() release.execute() if final_command: final_command.execute()
def type_playback(text): # Create an argument list for Playback from text. words = split_dictation(text) # Define the action to execute. # This will press enter a few times. Indentation will depend on your # editor. enter = Key("enter") + Pause("10") action = (Text('Playback([') + enter + Text('([%s], 0.0),' % words) + enter + Key("up, end")) # Move back only if no words were specified. if not text: action += Key("left:9") # Execute the action. action.execute()
class HardwareRule(MappingRule): mapping = { "volume <volume_mode> [<n>]": R(Function(navigation.volume_control, extra={'n', 'volume_mode'})), "change monitor": R(Key("w-p") + Pause("100") + Function(change_monitor)) } extras = [ IntegerRefST("n", 1, 50), Choice("volume_mode", { "mute": "mute", "up": "up", "down": "down" }) ] defaults = {"n": 1, "volume_mode": "setsysvolume"}