Quickly focus on a folder

I have all my projects nested underneath two top-level folders, one “Personal” and one for “Work”. I find it useful to focus on one or the other folder, depending on what I’m doing. This filters all projects and tasks in whatever perspective I happen to look.

I’ve discovered the ability to have save the focused state in a perspective, but that’s not what I’m after.

For example, I like focusing on the “Personal” folder in the projects perspective and then viewing my Today perspective (flagged & due) to only see my personal tasks for the day.

Is there a keyboard/menu/script by which I can switching between the two focused folders faster?

Hitting Cmd+O will open the “Quick Open” menu. You can start typing “Personal” and hit Enter, or you can type the name of the project. I’m guessing this is what you are looking for, hope it helps.

That’s a good suggestion. I don’t use the the “Quick Open” dialog enough. But it doesn’t work quite well. I have to unfocus, hit Cmd+O, type what I’m looking for, focus again, and then go back to the perspective I wanted.

So it’s actually not that fast.

What I was hoping to be able to do is bind Cmd+Shift+1 to “Focus on Personal folder” and Cmd+Shift+2 to “Focus on Work folder”. Or, have two toolbar buttons, one for each folder. I suppose the latter would be possible with AppleScript. But as a Mac neophyte and not sure where to look. Is there a similar script I could look at – perhaps to hack something for my use?

(BTW, because it’s only two folders, I wouldn’t have a problem hard-coding the values in the script. It wouldn’t need to be particularly clever.)

I now see that I didn’t fully understand your original question. Unfortunately I don’t have any experience with scripting OmniFocus. Sorry I can’t help!

Did you try creating two “today’s” perspectives? One for Work and one for Personal? :)

I use eight perspectives: Projects, Contexts, Today, Agendas, Plan, Forecast, Review and Stalled.

I would like to be able to view all of them while focused on either Personal or Work. Creating 16 perspectives isn’t workable.

It’s weird that there’s isn’t better support for this. Focusing on a top-level project seems to me a very manageable and straight-forward way of separating broad areas of your life. (I’ve seen it called “Workspaces” in other apps.) It works great, except for quickly switching between the various focused states.

I’ll have to get up to speed with AppleScript, methinks :)

I see. Yes, while it is the default behavior (changing perspectives keeps the focus) I understand what you mean that it isn’t so easy to change from one perspective to another fast.

Have you thought of of keeping two windows open?

For people like me that is a blessing because I know I usually plan how much time I am going to invest on a certain are of my life and I don’t need to fast switch. If I could it would probably ignite the squirrel brain mode hehe

But I’ll look over here, maybe I have an Apple Script that does that ready. I know I put together a script on Automator that changes the focus according to the time of the day (morning for blogging and master’s degree, afternoon for my business). I get back to you later if you would like :)

I did a bit more focused (heh) searching in this forum. Apparently, there’s already a solution:
https://discourse-test.omnigroup.com/t/set-focus-of-forecast-view-with-applescript/7364/2

I created two AppleScripts, one for each folder, gave them appropriate icons and added them to the toolbar.

Here’s what my “Personal” script looks like:

on run
	tell application "OmniFocus"
		tell the default document
			set folderList to folders whose name is "Alex"
			tell the front document window
				set focus to folderList
			end tell
		end tell
	end tell
end run

This script just changes the focused state, without altering the current perspective. Here’s what it looks like:

My “Personal” folder is actually called “Alex”. I was just using “Personal” and “Work” to describe what I trying to do. I’ll change the wording of the toolbar icons to correspond to my actual folders.


I see what you’re staying about the windows. I’m new to OmniFocus, so I probably fiddle with it more than I should. But I’ve found that when I’m looking at my task manager I’m in a pretty squirrelly state of mind anyway. When I want to focus deeply, I’ll often just go ahead and quit the app altogether. I’ve recently taken to using Alfred’s “Quit All Apps”. I can just then open the applications I can actually need for the work at hand.

FWIW, you can collapse this script like this

 on run
    tell application "Omnifocus" to tell the default document
             set folderList to folders whose name is "Alex"
             tell the front document window to set focus to folderList
     end tell
 end run

Since you only want one folder, I think this should also work …

 on run
    tell application "Omnifocus" to tell the default document of the front document window
             set focus to folders whose name is "Alex"
     end tell
 end run


JJW

I was just happy to scratch my itch :)

Your first version works, but the second one chokes. I don’t quite grok what’s the issue. Something is going on when you set the variable “folderList” that doesn’t happen when you combine the lines.

The error reported in the second case is:

The operation couldn’t be completed. /Users/alex/Library/Application Scripts/com.omnigroup.OmniFocus2/Alex.scpt: execution error: OmniFocus got an error: Can‚Äôt set document window 1 to every folder of default document of document window 1 whose name of it = “Alex”. (-10006)
H|zwˇ

I was following on my penchant to squeeze code to a minimum readable format. I doubt that what I created is noticeably faster. I have no clue either about the second form … It was just taking the squeeze to its logical conclusion. If I were to guess, I suspect that folderList, as a container, gets massaged internally to the proper format to be handled in the next code line.


JJW

The feedback is much appreciated. Do you know whether it’s possible to build a drop-down menu? So that I could do something like:

  • Personal [button]
  • Work [button]
  • More [button that opens a dropdown menu]
    • Someday/Maybe [option]
    • Horizons [option]

Preface the code with something like this …

 property pFolderList : {"Personal", "Work", "Family", "Others"}
 property pDefaultFolder : "Work"
 property pPrompt : "Which folder should be shown?"

 on run
	
	choose from list pFolderList ¬
		with title "Pick Folder" with prompt pPrompt ¬
		OK button name ¬
		"This One" default items pDefaultFolder
	
	if result = {button returned:"Cancel"} then
		return
	else
		set theChoice to the result
	end if
	
	if theChoice is "Others" then
		-- code here for yet another dialog box
		-- eventually return or set theChoice appropriately
	end if
	
 end run


JJW

Neat script. It requires a few more clicks than I’d like, but I think I’ll use it for something else I’m tinkering with. Thanks and sorry for the late response :)