Update (4/27/2020): See Enhanced text manipulation using accessibility APIs for an even better alternative to the dictation box!
When I find myself writing or editing something sufficiently long, I like to have full support for Select-and-Say. I used to use “open dictation box”, since that’s the obvious choice, until I discovered that using Notepad is much faster.
It’s kind of unbelievable that forking a process and starting a third-party editor could be faster than using the feature Nuance designed for this precise purpose. But amazingly it is, by a factor of about 2X! By my measurements, the dictation box starts up in about two seconds, whereas Notepad starts up in one. Transferring text from the dictation box takes about one second versus a half second for Notepad.
Just bind a few commands to make Notepad as easy to use as the dictation box:
from dragonfly import * from dragonfly.windows.window import Window class RunApp(ActionBase): """Starts an app and waits for it to be the foreground app.""" def __init__(self, *args): super(RunApp, self).__init__() self.args = args def _execute(self, data=None): StartApp(*self.args).execute() WaitWindow(None, os.path.basename(self.args), 3).execute() class UniversalPaste(ActionBase): """Paste action that works everywhere, including Emacs.""" def _execute(self, data=None): foreground = Window.get_foreground() if foreground.title.find("Emacs editor") != -1: Key("c-y").execute() else: Key("c-v").execute() # In your universal grammar: "edit text": RunApp("notepad"), "edit everything": Key("c-a, c-x") + RunApp("notepad") + Key("c-v"), "edit region": Key("c-x") + RunApp("notepad") + Key("c-v"), # In your Notepad grammar: "transfer out": Key("c-a, c-x, a-f4") + UniversalPaste(), # To get Emacs support, put something like this in your .emacs file: (setq frame-title-format '("" (buffer-file-name "%f" (dired-directory dired-directory "%b")) " - %m" " - Emacs editor"))
This gives you commands to start an editing session from several contexts: from nothing, from a selection, or from everything in your current field. And you get an easy way to transfer it out which works perfectly well with Emacs. Also, unlike the dictation box, this doesn’t prevent you from interacting with the existing app you have open (e.g. to visit another tab in Chrome). And if you accidentally mess up and paste it to the wrong place, it is still in your clipboard so you can easily recover it.
Of course, this same technique would work with another editor, it just needs to start up quickly and have full Select-and-Say support. Ideally, I would use it with an editor that has unlimited undo history. And if the editor can start in the background, this could be even faster by avoiding the process fork. If anyone knows a good candidate, please post in the comments!