Automator "Watch Me Do" function does not work in app

Solution 1:

Watch Me Do and Accessibility

Since macOS 10.9, you need to add your Automator application to your Mac's accessibility list. To add your Automator workflow, go to:

  • System Preferences →
  • Security & Privacy →
  • Accessibility

…and drag the Automator app you are trying to use into the list.

This is needed because Watch Me Do uses macOS's accessibility features to simulate user interactions. Accessibility is powerful and Apple require applications be explicitly listed before they are granted this additional control over your computer.

Solution 2:

Forget using Watch Me Do, it's kludgy and slow. You can use the following AppleScript code to toggle the state of the Menu bar and Dock.

Assuming that the state of both the Dock and the Menu bar are in sync. In other words, they are both always either showing or hidden together under normal usage and as such this script toggles the state of each to the opposite of the current state prior to its execution. If that is not the case, then additional logic needs to be applied.

tell application "System Preferences"
    activate
    reveal pane id "com.apple.preference.general"
    delay 1
end tell

tell application "System Events"
    click checkbox "Automatically hide and show the menu bar" of window "General" of process "System Preferences"
    key code 12 using command down
    tell dock preferences to set autohide to not autohide
end tell