Found an error with an AppleScript Workflow that I’ve had installed to my ~/Library/Services for a long time, but only now noticed that it doesn’t work when there are no Safari windows open.
My little workflow is something I’ve hacked from others’ work for automating an internal employee directory that doesn’t have any APIs but does let you hit a search URL which executes and returns in a browser window. If you want to look up someone mentioned in an email or other document you simply highlight the text, right click and choose the workflow from the Services context menu.
Now I’ll admit that I keep a whole lot of windows open on my desktop. So it’s pretty rare that I’ve closed every window in Safari. Even Safari itself will open a blank window of Top Sites when it starts up if you had all windows closed in the last session, and thus my workflow has never broken down until I discovered this unique (for me) use case: Safari is running, but all windows are closed. Only then would I get a non-descript message from Automator:
The action “Run AppleScript” encountered an error
reopen works much better for me, and once I replaced the
activate code my little service works fine.
Here’s the code with my little regex that extracts out only an email address if it finds one in the text you highlight, but otherwise just submits the text you highlighted: