Ask Mac Automator: Creating a Voice Command

I pleased to share my response to another Ask Mac Automator question. Though the workflow in response to this particular solution may not seem to apply to most people, it actually does, because it shows how the workflow in one application can be used in another to application to solve a particular problem. Here’s the problem:

Can you please help me find a way to open the Accessibility Keyboard quickly. At the moment I have to go to system preferences/Accessibility/keyboard/toggle keyboard on. I’ve made a feedback report to Apple for a quick toggle but it hasn’t been addressed. I’m a C3 complete tetraplegic with no hand movement and use a combination of head mouse, Keystrokes/dwell click and Dragon but both Keystrokes and Dragon have now stopped mac development so I am being forced to use Apple Accessibility keyboard and dictation. Thanks for any help you can  —Michael

By the way, Micheal is correct about Dragon Dictate. Nuance has abandoned the program. I still use Dragon Dictate, and only a few features don’t work. When I upgrade to Mojave, Dragon Dictate will probably no longer work. At this point, Apple’s voice-to-text dictation program is still underdeveloped. However, its dictation program is a good option.

Researching a Script

My first thought when thinking about a workflow solution was to see if Keyboard Maestro or Automator had an action to open Accessibility Keyboard in System Preferences. Unfortunately they don’t have such an action. So I did a Google search and discovered that someone had posted an AppleScript script that opened the Accessibility Keyboard. (Unfortunately I don’t have AppleScript skills, but most of the time when I do a search for a script I find a solution.)

I knew that the macOS Dictation feature ran Automator workflows, so I opened Automator and pasted the script in the Run Script action.

Alas, when I ran the script, it came back with error message that said, Automator “is not allowed assistive access.” WTF! Automator, a native macOS program, is not allowed assistive access? Has Apple abandoned the program that much?

Note: at the end of this article, there’s a summary all the steps for all the instructions.

The Keyboard Maestro Solution

Since Keyboard Maestro is a hundred times better than Automator, I knew it would be able to run the script, so I created a workflow using the Execute an AppleScript action.

Keyboard Maestro ran the script just fine and opened the Accessibility Keyboard. Now I just needed the Dictation Command to run the KM script.

AppleScript Trigger

Keyboard Maestro includes several ways to trigger an action, including an AppleScript script. For each KM macro an AppleScript script is created for the macro. You simply select it in the Trigger area of the macro editor.

So basically, I’m using a script to trigger the macro that triggers the AppleScript script. Hope that makes sense.

Now, to confuse you just a little more, I copied the script for the macro and inserted it in the Automator action, and I saved that action as an Automator Workflow, to be attached to the macOS dictation command.

Creating Dictation Command

Now we just need to create a Dictation Command, which is pretty easy.

Open System Preferences > Accessibility > Dictation

You will need to enable Keyboard > Dictation in System Preferences in order to use the Dictation Commands.

In Dictation, click on the Dictation Commands…button and click the + button to create a new dictation command.

Set up the command to run “While using > Application,” and then where it says, “Perform,” choose “Other” and attach the saved Automator workflow.

Where it says, “When I say:,” type the words you will use to trigger the command.

Issue the Command

Now the dictation command is created, all you need to do is run it by issuing the voice command.

You can actually leave Dictation Command running on your Mac, and it will only activate after you say your assigned keyword phrase.

Summary of Steps 

  1. Copy the AppleScript script. 
  2. Create a new Keyboard Maestro macro, and paste the script into the KM Execute AppleScript action. 
  3. Give the action a name, and copy the AppleScript trigger script.
  4. Paste the macro script into a new Automator workflow and save it as a workflow, not an application. 
  5. Open System Preferences > Accessibility > Dictation, and create a new Dictation Command. Add the Automator workflow to the command and give assign words for the command, (e.g., “Open Accessibility Keyboard”)
  6. Test the workflow by issuing the command with the Apple Dictation feature enabled. 

Your Turn

I hope the above workflow makes sense. It does require several steps, but once it’s created, it will save several clicks and mouse movements to open the Accessibility Keyboard.

Let me know what questions you have about the workflow and how you might use something similar in your own dictation command workflows.

You Have Question?

If you have an automation question, use this form to ask it.

 

  • Hi there, I really enjoy your site. I think it’s really well done and I hope you’ll keep up with it!

    Would you have any idea how I can use keyboard Maestro to tell Reminders to remind me of something at a specific time (as in, “Remind me to do X in 20 minutes”)?

    I can’t for the life of me figure out how to do this! Any advice you have would be much appreciated.

    • Hmm, I don’t use Reminders, but I thought Reminders sends a notification of the reminders put into it? KM does have a cron trigger that triggers based on the date and time you set. It also a daily and weekly time and day trigger that will send you notification. But it sounds like you want to KM to interrogate with Reminder, is that correct?

      • Thanks so much for your reply! I just want to be able to automate this: “Tell me to stop working in 45 minutes.” I usually use Siri to create a Reminder, but I’d prefer a key stroke. Your comment makes me think that I can skip Reminders altogether and just use Keyboard Maestro…. Interesting!!

  • >
    GET ACCESS TO SUBSCRIBERS-ONLY  Mac Automation Resource Library
    x
    %d bloggers like this: