3

I created a Calendar Workflow using Automator and I used "Watch Me Do" for one part of it. It worked fine for me when I tested but every time it would run overnight, it produced an error dialog box saying "OSStatus error -50". I know it isn't due to security issues because I had already worked through that problem during the interactive testing.

Based on the behavior that it works fine for me during testing but not overnight, I guessed that it might be related to the screensaver having kicked in. So I tried using a keystroke to end the screensaver but that didn't resolve my problem.

1 Answer 1

2

I couldn't find this answered anywhere so I wanted to post the problem I had and the solution I found here. The solution was to use "caffeinate" in my workflow. The first block of my Automator workflow is now "Run Shell Script" (/bin/zsh and to stdin) with the script:

caffeinate -u -t 180 > /dev/null 2>&1 &

That will end the screensaver by giving the computer something to do for 3 minutes and the spawn at the end ("&") means that the script doesn't need to wait for that to finish to run. Realistically, you could probably just do caffeinate for a single second and not bother spawning but no harm in doing it for 3 minutes.

After that block, the next block in the workflow is a "Pause" for 2 seconds just to give the computer time to truly be ready to run the workflow.

That resolved my OSStatus -50 problem.

And the way I was able to test this was to use Hot Corners with one of the corners set to "Put Display To Sleep". Then I would set the calendar event for two minutes in the future, move the mouse to the hot corner, the display would go to sleep and then I would wait some amount less than 2 minutes for it to wake and run my Automator workflow.

To be able to control your computer, remember to add your "app" that Automator creates to have access. That's in Settings > Security & Privacy > Accessibility, click to unlock, then + to add your app (if it isn't added already), and click the checkbox in front of it. I also found that after each edit to the workflow, I had to remove the "app" from the list of allowed applications and then add it back again. That's a major pain since there was tons of iteration to get this working.

1
  • 2
    Nice bit of research. :)
    – Tetsujin
    Oct 28, 2023 at 11:07

You must log in to answer this question.

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