MacOS – Record click action and replay via command line

accessibilityautomationautomatormacos

Every few minutes I need to click a button on Yosemite's menu bar and select an option. I'd like to automate this task by somehow recording this action and scheduling it to execute via cron / command line.

I've tried creating an Automator workflow using the "Watch Me Do" feature, but although it executes fine inside Automator, when I run automator myclicks.workflow in the Terminal, it gives me this cryptic error message:

The action encountered an error.

How can I get automator action to work?

Best Answer

So this might be an Accessibility issue. I was able to resolve it by going to System Preferences>Security & Privacy>Accessibility and then making sure Terminal had a check in the checkbox under Privacy.

This link does a great job of explaining it. Automator in Terminal

And by the way console can be very useful in getting meaningful error messages.

Hope this helped.