OmniFocus Actions Pack for Keyboard Maestro

Thank you for the feedback. I will try to update the installation instructions to include your advice. However, if drag-and-dropping the .zip created a duplicate folder, it means that the other folder probably contains an incorrect, invisible character (maybe a space at the end, or something else) - macOS does not allow the creation of two folders with the exact same names in the same location, so there must be a difference.

And you're right, the OmniFocusLibrary.scpt should be in ~/Library/Script Libraries:

  • Individual scripts interacting with OmniFocus should be in ~/Library/Application Scripts/com.omnigroup.OmniFocus3
  • Script libraries (libraries that provide common functions and procedures to other scripts) should always be in ~/Library/Script Libraries

@kornichon,

Thanks so much for your help here :slight_smile:

I’m a little puzzled because between this post and this post of yours (leaving the Third Party step out of things), cable0 seems to have fixed it in the way you intended, and not in the way assumed by dropping zips.

I take your point 100% about the impossibility of my having two apparently identically-named folders, Yes!

I did try it three or four times. the very first one I was copying and pasting 'Keyboard Maestro Actions’ from your OP.

Maybe the spaces weren’t consistently/correctly escaped?

Your confirmation on script libraries appreciated.

And thanks again for this very useful set of routines!

Omnifocus Set Project Name to 你好
Omnifocus Set Primary Tag of First Selected Task 你好

Project name is Chinese, Omnifocus Set Project Name and Omnifocus Set Primary Tag Does not work
how can i solve it?

Hello,

Can you try this version of OmniFocusLibrary.scpt ? I left a bug in the new version of the Library (as I warned, this new version of the library hasn't been time tested yet). The bug had nothing to do with the character set used, so it should work with Chinese characters.

OmniFocusLibrary.scpt.zip (482.1 KB)

this OmniFocus Library.script does not work.

https://cl.ly/e4941f1c6ddb/download/Screen%252520Recording%2525202019-08-28%252520at%25252005.11%252520PM.mov

Thank you for the video, it clarifies what's happening.

The way the action works is:

  • It executes an AppleScript script
  • The AppleScript script gets the parameters from the Keyboard Maestro Action, in particular the Tag Name
  • The AppleScript script then uses the OmniFocusLibrary.scpt to do its job.

After checking the value that I get in the Script from Keyboard Maestro, it seems that somewhere between Keyboard Maestro and the AppleScript script, the Chinese characters are converted to something, in my case 你好 in Keyboard Maestro becomes ‰Ω†Â•Ω in my script.

AppleScript can handle Chinese characters, so it seems the problem is in the "system attribute" AppleScript function of Keyboard Maestro (I say it seems, because I have no way to be sure). This is beyond my level of expertise, only Peter, the developer of Keyboard Maestro, could confirm me if Chinese characters can be passed to AppleScript. I'm sorry about that.

However, I do have a workaround for you. The advantage of using a Library is that you can call the procedures directly from Keyboard Maestro. Use an "Execute AppleScript" action in Keyobard Maestro, and add the script below. This script will assign the 你好 tag to your first selected task. It tested it with your tag and it works.

use OmniFocusLibrary : script "OmniFocusLibrary" -- use for production
set theTask to OmniFocusLibrary's GetFirstSelectedTask()
set theResult to OmniFocusLibrary's SetTaskPrimaryTagByName(theTask, "你好")

Ok, Thank you very much for the information

a question how does the Project solve ??


is correct?

Yes, it's correct!

SetTaskProjectByName will set the name of the project.

I remembered there is an even easier solution:

use OmniFocusLibrary : script "OmniFocusLibrary" -- use for production
set theResult to OmniFocusLibrary's SetFirstSelectedTaskPrimaryTagByName("tag_name")
set theResult to OmniFocusLibrary's SetFirstSelectedTaskProjectByName("project_name")

The first line, "use..." tells the script to use the OmniFocusLibrary script library.
The second line will set the primary tag of the first selected task.
The third line will set the project of the first selected task.

There are more procedures available, for example SetFirstSelectedTaskName("name") to set the name of the task.

To know more about the procedures available, you can simply open OmniFocusLibrary.scpt with Script Editor (simply double-click on the OmniFocusLibrary.scpt file.) I tried to document my code thoroughly, so every procedure has a short description for what it does, the expected arguments and what it returns.

use OmniFocusLibrary : script "OmniFocusLibrary" -- use for production
set theResult to OmniFocusLibrary's SetFirstSelectedTaskProjectByName("重要")

Error:

Can you try to translate the error message please? That would help me understand what's happening.

text-script: execution error: Variable “theProjectName Not defined(-2753)

I think I've found the reason: is your project empty? (no tasks)? There is a problem with the OmniFocus AppleScript command that moves tasks to projects when the project is empty. I'm sorry, I could not find a workaround for this problem. In the meantime, the best thing to do is to ensure that the project already has at least one task.

Let me know if this solves the problem.

If it helps, I was having exactly the same problem. As you say, it went away after creating a placeholder task in the project.

This is a great set of actions by the way. I found them a couple of hours ago and I'm already integrating them into my workflow. It's also given me a bit of an "Aha! So that's how you can use different palettes in different applications" moment that's going to keep me busy for a while. Thank you!

Hi,
The project is not empty, it is not yet solved
WechatIMG134

I'm sorry, I tried to replicate the problem, but can't. It works here with a project with foreign characters (i copy-pasted the characters in one of your previous message). As long as the project has at least one existing task, it works.

OK, thank you very much.

A couple of things I ran into that I hope can be addressed:

  1. I use emoji in my project names. The "Make Task" action doesn't seem to like that, since I get an exception, and then this is shown in Engine.log:
2019-11-18 15:01:20 /Users/juliant/Library/Application Support/Keyboard Maestro/Keyboard Maestro Actions/Omnifocus Make Task/Action.scpt: execution error: OmniFocus got an error: Can’t get flattened project 1 of default document whose name = "üå± Catch-All". Invalid index. (-1719)
  • I managed to test this with projects without emoji, and it works fine. For clarity, the project name is: ":seedling: Catch-All". This seems to be affecting tags as well. I use emoji in pretty much all tags/projects, so this kinda makes it a non-starter for me.
  1. Is it possible to specify more than one tag? The "Make Task" action is asking for a Context, which is a "deprecated" terminology since we use tags everywhere in OF now.

Any help you could give would be greatly appreciated. Thanks!

Hi, I'm discovering more and more different ways people use OmniFocus! I didn't even think about using emojis in project names. However this should be something that I should be able to test when I have the time.

For the multiple tag thing, I originally developed the action pack for OmniFocus 2, before tags were possible. I know I already tweaked some actions to take that into account, but as a strict GTD practitioner I don't use multiple tags, so I never modified the original actions to allow multiple tags. I'll check if I can modify it easily, probably using comma separated tags as the parameter.

You'll probably need a bit of patience though, I only do this in my spare time.

Sounds good! I'm not in any rush, just wanted to voice what I found. Let me know if there's anything that I can help with.

As for emojis in project names/tags, you should try it; really helps visualize and categorize things :slight_smile: