How to automate Voice Control to manipulate the currently selected text?
1
vote
1
answer
401
views
Because I have limited use of my hands, I use Voice Control to dictate most of my text. (I'm using it to speak this question.) Voice Control offers the ability to add custom commands, including those that will run an Automator workflow. Automator, in turn, can execute arbitrary JavaScript or AppleScript. (I prefer JavaScript). What I want to do is to create a script that takes the currently selected text in whatever application is active, manipulates it, and then replaces the selected text in place. For example, imagine creating a "hyphenate this" command that converts selected text like this—"Mac Voice Control scripting"—and changes it to this—"Mac-Voice-Control-scripting". Writing the JavaScript or AppleScript to transform the string is the easy part. The problem is how to get the currently selected text for the current application, whatever it may be.
In Automator, you can create a "Quick Action" workflow that is supposed to pass the currently selected text and enable you to replace it. In practice, however, in Big Sur (at least) I could not get this workflow to receive text from any application. Given a standard
()
function, the
array was always of length 0.
How do I create a workflow that may be executed by a custom command in voice control that receives, processes, and replaces the currently selected text in the current application?
Asked by Jeff Wofford
(135 rep)
Jan 2, 2021, 07:16 PM
Last activity: Jan 2, 2021, 10:58 PM
Last activity: Jan 2, 2021, 10:58 PM