Search code examples
speech-recognitionpython-dragonfly

Can Dragonfly be used to modify existing text, like "Capitalise That" in DNS does?


As an example, I have written a simple rule to camelCase text. It uses the following spec:

spec="camel case <txt>"

which correctly modifies the text said after the command 'camel case'.

But this still isn't as flexible as built-in commands like "Capitalise That" are.

For example, "Capitalise That" can be used to operate on the text currently selected by the mouse. That makes it very easy to edit existing code.

Can this functionality be achieved in dragonfly?


Solution

  • Yes, but you'll have to get creative. Use a Dragonfly Function Action to press keys to highlight the text you want to capitalize. (For example, Shift-Right or Control-Shift-Left.) While still in the function called by the Function Action, read the text by sending keys for Control-C, then getting the contents of the clipboard. Then you can modify it however you want and print it back out.