Automate sorting in omnifocus

Is it possible to use Keyboard Maestro to automatically organize/sort/filter task entries in omnifocus to be moved to certain contexts or projects based on the text of the entry?

For example, I make a lot of reminders via Siri to “listen to __” or “share ___ on Facebook.” Now, I manually go thru my omni inbox and send these to contexts/projects like “listen to” and share on Facebook” - but is it possible to have the text searched so that if (for example) it says Facebook in the task entry then it will automatically go to that “share on Facebook” context?

I did a Google search, and it looks like OmniFocus supports AppleScript, and you can certainly run AppleScripts from KM, so my guess is that the answer is “yes”.

I can’t answer the “how” question, as I don’t have OmniFocus. But perhaps someone else will jump in here.

1 Like

Thank you for your input. Would appreciate it if any omni users could jump in here, i’ve never used applescript before and not sure where to start. I think alot of people in addition to myself might benefit from this kind of macro

I’m not an Omni user, but maybe this will help.

Can you accomplish your objective manually using Omni menu items, after the item in the Omni Inbox is selected?

If so, you could do this:

  1. Read the Inbox Item to look for the keywords of interest
  • You might try a normal copy of the item, and then paste into a plain text editor like TextWranger to see what plain text is available
  • If the keywords are in this text
    • you can just do a KM Copy
    • Use a KM Switch/Case action to branch based on the found keyword
  • OR, use AppleScript to read the selected Omni item and get the necessary data, and store this in KM Variables
  1. Use a KM Menu Action to execute the Omni menu items necessary to process your item.

It doesn’t seem like i can use the Omni menu (on the top of the screen), but i have set up Keyboard Maestro macros to send the item to projects with the keyboard or mouse click macros.

Ok i put it into textwrangler and all of the item title shows up, inckuding keywords

What is a KM Copy?

And its my first time with the Switch/Case action- I see I can choose for the Text to contain words, or a clipboard to contain words. How would i set this up? When im in omnifocus, would i need to copy each item individually to set to run through this macro? Or could it be made automatic so that each item entered would go thru the macro without my interaction?

Wondering if i’m getting in over my head with this…

Thanks again for your help

I think he means “use a Copy action in Keyboard Maestro”.

1 Like

I don’t think so, but it may require some research and trial and error on your part.
Just be prepared for it to take some time to complete your first complex KM Macro.

As @DanThomas said, the Keyboard Maestro Copy Action

  1. Use the KM Copy Action to copy the item Title to the clipboard.
  2. Use a Set Variable Action to set a KM Variable (like “Omni_Title”) to the clipboard.
  3. Use a Switch/Case Action based in this Variable
  • For each Case in the Switch, you could use a RegEx that matches the keyword

But I’m really just guessing in the above, since I don’t have the Omni app.

It would be best if you could record a video, with sound, where you manually go through your entire workflow for one Omni Item. Be sure to go slow, and verbally state what you are doing, especially with any Mouse actions. There are many tools for recording screen video, but you can use the Mac QuickTime Player if you don’t have any of the specialty tools.

Good luck, and let us know if you’re willing to create the video.

Ok thanks, I’ve checked out KM copy action and Switch/Case action, not sure how it will work yet but will dedicate some more time to learning them later in the week. I have taken a video of the workflow and published it here:

Please let me know if theres anything i left out

OK, thanks. That was very helpful.

Since I do NOT have Ominifocus, you will need to do all of the exploratory testing I would normally do during development.

I feel confident that everything you want to do can be done via AppleScript.

I just found this tool. Please review it in detail to see if it will do what you need, or if you can use script snippets from it:

OmniFocus Auto-Parser