I have several macros I use in OmniFocus so that I can edit tasks quickly. For example, if I put a link to an article in my Inbox, I have a macro I can use later when I'm processing inbox actions called "Read It Later." When triggered, it walks through the steps of assigning a project and a context to the task (which I'd normally have to click and type several times to do), then it refreshes the list.
All my other macros work fine, but when I use the one mentioned above, it stops in the "context" field and types a capital letter "I" as in "India." Just stops dead. When I try Debug Mode and advance it one step at a time, it works fine. Is this another one of those "you need a pause" situations?
Note: Ignore the unconventional hot key; I use Karabiner Elements to map my CAPS LOCK key to a HYPER key and it works fine in other macros. I also don't think I have any TextExpander snippets that are being triggered during the execution of the macro; again, it works fine during debug mode. Any ideas?
Good to know! This is a thing I’d normally do via AppleScript, since any changes to the OmniFocus interface would interact poorly with this type of macro.
@cfriend – I know what you mean. Could I see a sample of one of your scripts?
On the other hand, I find scripts become obsolete over time as well, so in my mind it’s 6 of one, half a dozen of the other, and it’s quicker to just adjust a KM macro than do some script editing for a non-coder like myself. I find scripts online all the time to do something amazing in OmniFocus but it’s always from several versions back of either OF or MacOS, and they no longer work when I come across them. For example, I’ve seen scripts that promise to export or import between outliners/mindmap programs and OF, but when I try them there’s always so much debugging involved that hours are wasted.
I’m a rookie too, and have a few that create tasks with certain project/context values, but none that set them for already created tasks. There are some for context on the OmniFocus forum, ie:
-- unlocked2412
-- This script sets a specific context to the currently selected tasks.
property the_context_name : "" -- CHANGE THIS PROPERTY VALUE TO REFLECT YOU DESIRED CONTEXT
tell application "OmniFocus"
set o_doc to front document
tell o_doc
set the_context_value to first flattened context whose (name = the_context_name)
end tell
set o_win to front document window of front document
tell o_win
tell content
set lst_tasks to value of selected trees
if lst_tasks ≠ {} then
repeat with i in lst_tasks
set the_task to contents of i
set context of the_task to the_context_value
end repeat
else
display dialog "Select one or more tasks, please."
end if
end tell
end tell
end tell
and
-- unlocked2412
-- This script sets a specific project to the currently selected tasks.
property the_project_name : "" -- CHANGE THIS PROPERTY VALUE TO REFLECT YOU DESIRED PROJECT
tell application "OmniFocus"
set o_doc to front document
tell o_doc
set the_project_value to first flattened project whose (name = the_project_name)
end tell
set o_win to front document window of front document
tell o_win
tell content
set lst_tasks to value of selected trees
if lst_tasks ≠ {} then
repeat with i in lst_tasks
set the_task to contents of i
move the_task to end of tasks of the_project_value
end repeat
else
display dialog "Select one task, please"
end if
end tell
end tell
end tell