hi all,
Relatively new to UI scripting with AppleScript, but not to scripting/coding in general, and I’d really appreciate any assistance with this wall I keep hitting.
I have a couple of “dashboard”-type applescripts that pop up a bunch of OF windows to different perspectives and tile them in a way that I like. One wrinkle I’ve been trying to iron out is that I want the sidebar settings on these windows to be consistent. I’m trying to do this by having System Events click the Hide Toolbar menu item, but System Events seems not to be able to address the Omnifocus process. Below is a test script that shows the problem with the simple example of opening a new window. Every one of these blocks works, except the Omnifocus one! That one throws this error: “System Events got an error: Can’t get process “Omnifocus”.” number -1728 from process “Omnifocus”.
tell application “System Events” to tell process “Finder”
click menu item “New Finder Window” of menu 1 of menu bar item “File” of menu bar 1
end tell
tell application “System Events” to tell process “Safari”
click menu item “New Window” of menu 1 of menu bar item “File” of menu bar 1
end tell
tell application “System Events” to tell process “Chrome”
click menu item “New Window” of menu 1 of menu bar item “File” of menu bar 1
end tell
tell application “System Events” to tell process “Omnifocus”
click menu item “New Window” of menu 1 of menu bar item “File” of menu bar 1
end tell
I’m on Mojave and I know there are permissions weirdnesses with automation. I have Script Editor and Omnifocus added to the Security and Privacy > Accessibility pane. I have also done similar things successfully in the past by saving the script as an app and then adding the app to Accessibility pane, but I don’t understand why that would be necessary for Omnifocus when it clearly isn’t necessary for e.g. Chrome.
Thanks for any assistance!
G