I'm trying to run pmset sleepnow linked to a keyboard shortcut with automator. When I use the shortcut, it's giving me a 'Cancel' or 'Continue' prompt. Anyway to skip this so the script just runs when I press the key combo?

  • Like ʀ2ᴅ2, I too cannot reproduce your issue. I'd suggest you edit your question to include additional information to help us diagnose/troubleshoot. – user3439894 Oct 29 '18 at 12:19

I'm not able to replicate your prompt issue if I code the sleepnow in a do shell.

  • Launch Automator
  • Go to File > New
  • Select Service and click Choose
  • Select "No input" in drop-down list
  • Select in drop-down list "Any application"
  • Select "Run AppleScript" and double-click or drag and drop
  • Replace the script with a do shell
  • Save the service
  • Add service in keyboard

enter image description here

The code:

    display notification "Attempting sleep"
    delay 2
    set result to do shell script "pmset sleepnow"
on error result
    display dialog result
end try

The service with shortcut:

enter image description here

System specs:

macOS Sierra Version 10.12.6 on Macbook Pro

  • There should not be a need to use a Run AppleScript action when all that's needed is a Run ShellScript action with simply pmset sleepnow as the command. – user3439894 Oct 29 '18 at 12:21
  • Well if there was an error to occur it will render the error. – ʀ2ᴅ2 Oct 30 '18 at 13:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .