The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus 1 for Mac (http://forums.omnigroup.com/forumdisplay.php?f=38)
-   -   Some OmniFocus Scripts (http://forums.omnigroup.com/showthread.php?t=3880)

curt.clifton 2007-06-17 05:59 PM

Some OmniFocus Scripts
 
I posted some OmniFocus scripts in various threads on the forum. I decided to put these on a web page for easier updates. The scripts include:
[LIST][*]one to generate OF projects from selected OmniOutliner items;[*]one to generate new OF projects from template projects, complete with replacing placeholders and setting dates; and[*]a pair to create OF actions from Mail messages and to jump from the actions back to the message.[/LIST]
You can download all the scripts from [URL="http://www.rose-hulman.edu/~clifton/software.html"]my software downloads page[/URL]. If you find the scripts useful you can subscribe to [URL="://www.rose-hulman.edu/~clifton/software/feed.xml"]my RSS feed [/URL]to be notified when I post updates.

Cheers,

Curt

curt.clifton 2007-06-20 07:02 PM

I just realized that [URL="http://www.rose-hulman.edu/~clifton/software/feed.xml"]my RSS feed[/URL] was pointing to my development server on my localhost. Sorry if you tried the feed and had problems. It should be fixed now.

zxspectrum 2007-06-22 11:17 AM

very nice..
 
thanks for a great script...the only thing that is a bit annoying is the painful 'link back to mail message'...hopefully you can fix this?


thanks again.

curt.clifton 2007-06-22 12:57 PM

[QUOTE=zxspectrum]thanks for a great script...the only thing that is a bit annoying is the painful 'link back to mail message'...hopefully you can fix this?
[/QUOTE]

Do you mean "painfully slow"?

I've gone about as far down that road as I can. We'll have to wait for Apple to fix Mail.app's scripting interface. For now, using the Mail Act-On rules with archiving, as detailed in the included instructions, is your best bet until Leopard is released (or Omni bakes mail links into OmniFocus).

Cheers,

Curt

connie 2007-06-30 03:26 PM

the scripts are very helpful. thanks. I'm not sure how to open a url from inside Omnifocus. It is a cut and past to safari or does it have a link? thanks

curt.clifton 2007-06-30 04:07 PM

Connie,

I assume you're talking about the Send URL from Safari script?

I currently open the actions note, select the URL, right-click the URL, and choose Open Link. I'll plan to eventually integrate the scripts so a single Follow Link script will look at the note field, decide where to jump (Mail, Safari, ...), and then jump there. It'll be awhile before I get to that though. Lots of home improvement projects in the hopper right now.

isam 2007-07-13 01:57 PM

Isn't there a way to uniquely Id a message, and link back to it more efficiently ? it seems that the "set theMessage to the first message of theMailbox whose message id is theMessageID" is very inefficient (is the slowness from it ?)

curt.clifton 2007-07-13 02:38 PM

[QUOTE=isam]Isn't there a way to uniquely Id a message, and link back to it more efficiently ? it seems that the "set theMessage to the first message of theMailbox whose message id is theMessageID" is very inefficient (is the slowness from it ?)[/QUOTE]

Yes, that is the source of the slowness. And yes, there is a way to uniquely ID the message, but only with MailTags installed. Apple does not provide script-based access to arbitrary messages by ID. Trust me on this, I've spent many hours trying various work-arounds. Mail.app's AppleScript interface sucks eggs. The "engineers" who built it should be embarrassed.

MailTags costs $29.95. That will buy you fast opening of arbitrary messages by ID, plus a bunch of nice meta-data facilities for Mail.app. Unfortunately, MailTags's fast opening feature does not display messages within their threads. They open in separate windows.

I've personally decided that MailTags is worth the investment. Future versions of my OmniFocus-Mail scripts will require MailTags for link-back. (The previous version without MailTags will also remain available for the foreseeable future.)

isam 2007-07-14 12:55 AM

From Today's "Message of the Day":
- MailTags' message urls are now automatically recognized in notes.

I hope this will be a big boost for using MailTags with OF

curt.clifton 2007-07-14 06:21 AM

[QUOTE=isam]From Today's "Message of the Day":
- MailTags' message urls are now automatically recognized in notes.

I hope this will be a big boost for using MailTags with OF[/QUOTE]

I think so.

I posted [URL="http://www.rose-hulman.edu/~clifton/software.html"]new versions of my scripts[/URL] last night that use MailTags. (We're replacing a domain server today—Sat., July 14—so the link may only work sporadically.)

pjb 2007-07-14 06:25 AM

Is the new Mail in Leopard going to have some of this tagging built in?

curt.clifton 2007-07-14 07:50 AM

[QUOTE=pjb]Is the new Mail in Leopard going to have some of this tagging built in?[/QUOTE]

My scripts aren't really taking advantage of tagging, just MailTags's fast linking directly to Mail messages. If Leopard Mail provides better AppleScript support for opening messages, then I will probably eliminate the dependency on MailTags.

smorr has posted [URL="http://www.indev.ca/forum/viewtopic.php?t=940"]a compare-and-contrast table for Leopard Mail vs. MailTags[/URL]. As the developer of MailTags he certainly has a vested interest, but the comparison seems valid to me.

Danoz 2007-07-14 10:27 PM

Hi Curt,

I have downloaded and tried to use the Populate Template script, But I run into the following error:

[QUOTE]OmniFocus got an error: Can't make root task of task id "eS6O-B1pQd5" of document id "o5x33Qg9Atx" into type reference.[/QUOTE]

Script Editor hangs on this line:
[QUOTE] set theTask to {(get root task of selectedItem)}
[/QUOTE]

Changing this to:
[QUOTE] set theTask to {(get root task of selectedItem)} as reference
[/QUOTE]
*I can't remember exactly where I put the as reference, inside the brackets or braces or outside*
seems to fix this issue, but then I get another similar error down in the "onReplacePlaceholders" module.

Any suggestions as to what I can do?

Thanks.

curt.clifton 2007-07-15 05:50 AM

Danoz,

I'm able to replicate the error. It occurs when you try to use the script on a subproject. Currently the script only handles top-level projects. Good catch!

I'll fix the bug and post a new script.

curt.clifton 2007-07-15 06:12 AM

The new version of my Populate Template Placeholders script is available from [URL=http://www.rose-hulman.edu/~clifton/software.html]my software downloads page[/URL].

johnrover 2007-07-15 11:00 AM

Curt– Thanks again for these awesome scripts.

Is it possible to set the default context? or perhaps a handful of default contexts with different Act on key combinations for each?

curt.clifton 2007-07-15 11:49 AM

[QUOTE=johnrover]Is it possible to set the default context? or perhaps a handful of default contexts with different Act on key combinations for each?[/QUOTE]

It would be straightforward to hardcode a context in the script. You could make copies of the script for each context, then fire the one that you want from the Act-On rule.

Danoz 2007-07-15 06:48 PM

[QUOTE=curt.clifton]Danoz,

I'm able to replicate the error. It occurs when you try to use the script on a subproject. Currently the script only handles top-level projects. Good catch!

I'll fix the bug and post a new script.[/QUOTE]

Thanks so much Curt.

I understood from one of your other posts that you made a new project called "Templates" and inside that project you stored your (well...) templates. So these were then sub-projects, I guess.

This is how I set up my templates area to work with your script. Did I misunderstand you? Anyway, it should be resolved now.

Thanks again.

Update...
In running the script as I intimated above (my templates are all stored in an on hold project called "Templates" and my templates are all sub projects there), the script does not run at all. It errors out at the first instance, suggesting I don't have a project selected.

I tried moving the template out and made it a new project in it's own right - ie it showed up in the left hand column of all projects, but still encountered this problem.

Any suggestions? How could the count of projects or trees be < 1? I definitely have it selected.

Thanks.

curt.clifton 2007-07-15 07:08 PM

[QUOTE=Danoz]
I understood from one of your other posts that you made a new project called "Templates" and inside that project you stored your (well...) templates. So these were then sub-projects, I guess.

This is how I set up my templates area to work with your script. Did I misunderstand you? Anyway, it should be resolved now.[/QUOTE]

I use a top-level [I]folder[/I] called Templates with projects inside it.

[QUOTE=Danoz]
In running the script as I intimated above (my templates are all stored in an on hold project called "Templates" and my templates are all sub projects there), the script does not run at all. It errors out at the first instance, suggesting I don't have a project selected.[/QUOTE]

You need to select the project in the main content pane, not in the sidebar.

Keith 2007-07-19 09:43 PM

[QUOTE=curt.clifton]I think so.

I posted [URL="http://www.rose-hulman.edu/~clifton/software.html"]new versions of my scripts[/URL] last night that use MailTags. (We're replacing a domain server today—Sat., July 14—so the link may only work sporadically.)[/QUOTE]


The "Add OmniFocus Action" script did nothing for me until I deleted the "on assistiveDevicesSupportEnabled()" by revising it to automatically return a "true" result:

on assistiveDevicesSupportEnabled()
-- check to see if assistive devices is enabled
return true
end assistiveDevicesSupportEnabled

It seems to have been choking on the "set UI_enabled to UI elements enabled" line. Now it works fine. (I already had assistive devices enabled, of course; could it have made a difference that I am running the Finder and all my other programs in Japanese?)

As for the "Open Linked Mail Message" script, it works when I run it from the Script menu or from ScriptEditor, but not when I run it by clicking it in the OmniFocus toolbar. Odd.

curt.clifton 2007-07-20 04:58 AM

[QUOTE=Keith]The "Add OmniFocus Action" script did nothing for me until I deleted the "on assistiveDevicesSupportEnabled()" by revising it to automatically return a "true" result:

on assistiveDevicesSupportEnabled()
-- check to see if assistive devices is enabled
return true
end assistiveDevicesSupportEnabled

It seems to have been choking on the "set UI_enabled to UI elements enabled" line. Now it works fine. (I already had assistive devices enabled, of course; could it have made a difference that I am running the Finder and all my other programs in Japanese?)[/QUOTE]

Thanks for that report. I suspected that non-English localizations might be affecting that code. It's a bit surprising though, since that code is based on an example provided by Apple.

[QUOTE=Keith]As for the "Open Linked Mail Message" script, it works when I run it from the Script menu or from ScriptEditor, but not when I run it by clicking it in the OmniFocus toolbar. Odd.[/QUOTE]

That is odd. It works fine from the toolbar for me. Have you tried restarting OmniFocus?

Keith 2007-07-22 08:03 PM

[QUOTE=curt.clifton]That is odd. It works fine from the toolbar for me. Have you tried restarting OmniFocus?[/QUOTE]

Thank you, yes, I have tried restarting. Puzzling, the script is running from the toolbar, it just isn't doing anything. When I click the script in the toolbar with nothing selected, I do get the "You must first select a project or action" message, so the script is definitely running. But when I select a project or action and click the toolbar, it doesn't seem to cause Mail to do anything.

A more significant problem (for me, anyway): the script does not recognize which window has the focus. I have three OmniFocus windows open on three monitors, but it seems that the "Open Linked Mail Message" script will only ever work in one window, namely, the first window opened when the program is launched (although if the other two windows are closed, then it becomes possible to run the script in the sole remaining window, even if it was not the first window opened when the program was launched). Even if the foremost window (the window with focus) contains a selected project or action, the script will act only based upon the selection (or lack of any selection) in the window which it believes has the focus, i.e., the first window opened when the program was launched.

In the script I tried changing "tell document window 1" to "tell front document window" but it didn't have any effect.

curt.clifton 2007-07-23 04:04 AM

[QUOTE=Keith]Thank you, yes, I have tried restarting. Puzzling, the script is running from the toolbar, it just isn't doing anything. When I click the script in the toolbar with nothing selected, I do get the "You must first select a project or action" message, so the script is definitely running. But when I select a project or action and click the toolbar, it doesn't seem to cause Mail to do anything.[/QUOTE]

The script is very likely triggering an error, which is swallowed by OmniFocus. To check, follow these steps:

1. When you get a situation where the script appears to do nothing, leave OmniFocus alone so that selections and focus don't change.
2. Open the script in Script Editor and run it from there.
3. Note any errors messages that are displayed.

[QUOTE=Keith]A more significant problem (for me, anyway): the script does not recognize which window has the focus. I have three OmniFocus windows open on three monitors, but it seems that the "Open Linked Mail Message" script will only ever work in one window, namely, the first window opened when the program is launched (although if the other two windows are closed, then it becomes possible to run the script in the sole remaining window, even if it was not the first window opened when the program was launched). Even if the foremost window (the window with focus) contains a selected project or action, the script will act only based upon the selection (or lack of any selection) in the window which it believes has the focus, i.e., the first window opened when the program was launched.

In the script I tried changing "tell document window 1" to "tell front document window" but it didn't have any effect.[/QUOTE]

That sounds like an OF bug. I've reproduced it and reported it.


All times are GMT -8. The time now is 03:33 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2021, vBulletin Solutions, Inc.