One potential route I thought of but lack the expertise to do:
- Pull up the list of tasks from the current perspective.
This can be done utilizing the code from this function (though made to loop through all instead of randomize):
– Run this script to select a random task in your current view. It probably won’t work with nested tasks.
tell application id “com.omnigroup.OmniFocus2”
tell default document
tell the front document window
set theTasks to tree of content
set randIdx to random number from 1 to the length of theTasks
repeat with aTask in theTasks
set aTask’s selected to false
end repeat
set theTask to item randIdx of theTasks
set theTask’s selected to true
return theTask’s name
end tell
end tell
end tell
FOR EACH TASK (loop through each):
- Rename it to add “[SuperFocus]” or something to the end of the task name.
- Still in the loop, call this function to search for all tasks with “[SuperFocus]” in the name (aka, just the one above):
on run
set my_dialog to “[SuperFocus]”
set search_perspective to “Search Remaining”
tell application id “com.omnigroup.omnifocus2”
activate
tell default document
tell first document window
set perspective name to search_perspective
set search term to my_dialog
end tell
end tell
end tell
end run
-
Still in the loop, display a dialogue with “completed” and “skip” options (and potentially “stop”):
-
If “completed” marked, mark the task in OF as completed.
If “skip” marked, do nothing for this step.
If “stop” marked, the entire script finishes then and there.
-
Remove “[SuperFocus]” from the task’s name.
So step one gets the list of tasks, and each task gets steps 2-6 applied to it.
The idea, then, is that the script will pause at step 4 (the dialogue with “completed” or “skip”) until the user selects an option - which may be in a second or 5 hours, shouldn’t matter.
Caveat: to keep it simpler, the assumption is that the user will “stop” the script if they change the tasks in the perspective partway through (particularly if they remove a task outside of the script’s functionality, which may have the program screw up?).
If anyone has the knowledge to do it, I don’t think it would be a super difficult script to write, but it would be awesome :).
Bonus points if they can put it in a button on the top of OF, much like the famous “Complete and Await Reply” and “Verify Next Actions Exist” scripts.
Anyhow, my two cents!
EDIT: I’m trying to work some on my own, but running into an issue. Here’s what I have so far:
tell application id “com.omnigroup.OmniFocus2”
activate
tell default document
tell the front document window
set theTasks to tree of content
-- Run Array
repeat with aTask in theTasks
set display_name to get name of aTask
display alert "Now looking at " & display_name
set name of aTask to "test"
end repeat
end tell
end tell
end tell
However, I get the error:
OmniFocus got an error: Can’t set name of tree to “test”.
I can’t seem to figure out what a “tree” is, especially when I can get display_name from “name of aTask” but can’t edit “name of aTask”?
Any help here would be great :).