Created
April 2, 2025 20:44
-
-
Save offlinemark/54d0f42f2c00f8b3e8ebb9fd7c50785f to your computer and use it in GitHub Desktop.
apple script for focusing on an omnifocus folder, with chooser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on run | |
-- Preselected folder names (replace with your own folder names) | |
set preselectedFolders to {"Life", "Work", "Media"} | |
-- Display a chooser dialog to select a folder | |
set chosenFolder to choose from list preselectedFolders with prompt "Choose a folder to focus on:" default items {"Life"} | |
if chosenFolder is false then return -- user canceled | |
-- Get the selected folder name from the list | |
set chosenFolder to item 1 of chosenFolder | |
-- Tell OmniFocus to find and focus on the selected folder | |
tell application "OmniFocus" to tell the default document | |
-- Find the folder(s) whose name exactly matches the chosen folder name | |
set folderList to folders whose name contains chosenFolder | |
if folderList is not {} then | |
tell the front document window to set focus to item 1 of folderList | |
else | |
-- Alert if no matching folder is found | |
display alert "Folder \"" & chosenFolder & "\" not found." | |
end if | |
end tell | |
-- Unfold (expand) the complete folder hierarchy in the sidebar | |
tell application "System Events" | |
tell process "OmniFocus" | |
set frontmost to true | |
-- Option 1: Try clicking the "Expand All" menu item from the "View" menu | |
click menu item "Expand All" of menu "View" of menu bar 1 | |
end tell | |
end tell | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
to install keyboard shortcut for this: