Focus in New Tab

I’m a big fan of Dan Bylar’s ‘Focus in New Window’ applescript in order to keep a reference to my last place. With MacOS Sierra’s built-in tabs, I’d like to adapt this to ‘Focus in New Tab’. I was poking around his applescript as well as the OF Dictionary and couldn’t find a way for that to work. Am I missing something or will that require an extension to the OF Dictionary?

2 Likes

I’m not 100% sure but I think first Omnifocus the app need to support tabbing as per the default MacOS Sierra, which I don’t currently think it does. I can’t for instance create a new window and merge them as tabs (like the finder). I think if Omnifocus supported tabbing in principle that should ‘just work’ and then you could find out how to make a ‘focus in new tab’ applescript to work.

Hey Kraig,

I just added a version that focuses in a new tab. Because OmniFocus doesn’t currently have native AppleScript support for managing tabs, there are a couple requirements:

  1. UI Scripting Access needs to be enabled. For more information, see Mac Automation Scripting
  2. You need a Projects-based perspective called “Projects”. (This should be enabled in any default OmniFocus installation so you probably don’t need to do anything special here.)

Also, tabs are dependent on macOS Sierra.

Direct download link

Cheers,
Dan

2 Likes

UPDATE: Turns out there’s a little more jiu jitsu needed to get this running in the OmniFocus toolbar. The download link has been updated with the helper script and application bundle needed for this.

Setup:

  • Save the script as an application (“FocusTabApp” in the zip file, or you can do this from Script Editor)
  • Move FocusTabApp and FocusTab (the helper script) to the OmniFocus scripts folder (OmniFocus → Help → Open Scripts Folder)
  • Add FocusTabApp to your allowed applications in System Preferences → Security & Privacy → Privacy → Accessibility
  • Add FocusTab to the OmniFocus toolbar
  • ONLY IF NEEDED: Update the helper script (“FocusTab” in the zip file) to point to to the location of FocusTabApp

Why is this necessary?

  1. As mentioned above, to use UI scripting, an application needs to be granted explicit access in the System Preferences → Security & Privacy → Privacy → Accessibility. (For more information see https://developer.apple.com/library/content/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/AutomatetheUserInterface.html)
  2. AppleScripts cannot be granted acccess in this way.
  3. OmniFocus does not allow application-type scripts in the toolbar.

What’s the “helper script”?

do shell script "open -a ~/Library/Application\\ Scripts/com.omnigroup.OmniFocus2/FocusTabApp.app"

2 Likes