On Mac I’ve learnt how to create projects and add tasks - with AppleScript. (So now I can automate and create many more projects scalably, which is very useful to me.)
In common with other AppleScript dictionaries the OmniFocus one is inscrutable to me. One thing in particular I want to do is, having created a project, to switch to it in the Mac app.
How do I switch projects in the Mac app from AppleScript?
(Today my workaround is to issue Cmd+Down+Arrow from the script.)
I am, by the way, driving aspects of OmniFocus with AppleScript from MetaGrid buttons on iPad. It saves lots of keyboard interaction.
I will look if this is possible when I reach my computer in a couple of hours. I haven’t coded regularly in this language since 2018 (despite working on very specific projects).
Any particular reason you chose AppleScript over JavaScript For Automation ?
I understand that. Despite its “English-like” syntax, AppleScript is a difficult and not intuitive language.
I don’t much like AppleScript either. No particular reason for AppleScript over JXA - except that’s what I started with and got the rest of the code working as.
Looking forward to any resolution or clarity you can bring. And this being a forum it’d be beneficial for unspecified future searchers. :-)
Just looked into this. It is possible. Three variants of the solution, below.
Tell me if you have further questions.
AppleScript:
-- Create new project and display in Projects perspective
tell application "OmniFocus"
tell default document
set oProj to make new project with properties {name:"Plant a Tree"}
tell first document window
set perspective name to "Projects"
set nodes to trees of sidebar whose id = (id of oProj)
set selected trees of sidebar to nodes
end tell
end tell
end tell