The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Combining Tasks Thread Tools Search this Thread Display Modes
Still over 13 seconds to combine the same two emails on my machine, but it does work on Inbox items now.

Since that was only my second ever AppleScript, allow me to ask you a quick question...

What's the benefit of
tell application id "com.omnigroup.omnifocus"
versus
tell application "OmniFocus"
?
 
The stakes are not high.
Apple's guidelines recommend the id + bundlename identification on the grounds that the bundle name is less likely to change across versions than the application name.
(I use, for example, one or two apps which actually include the version string in their application name).

(The main bottleneck in speed tends, incidentally, to be "Apple Event" traffic between the applescript interpreter and an application. The format-preserving version of action-merging involves much heavier apple event traffic than the version which fetches plain text. Hence the 13 seconds on your system).
 
Might there be a performance advantage to doing the copying of the formatted text via System Event scripting?
 
Quote:
Originally Posted by whpalmer4 View Post
Might there be a performance advantage to doing the copying of the formatted text via System Event scripting?
That's an interesting thought. It might well reduce the volume of traffic. A good case for an experiment, I think.
 
FWIW, I was looking at the formatting-enabled version of the script last night. All of the time is spent in the single "duplicate characters..." statement so there's really not much to be done about tuning it. But I also have a warning for johnrover and anyone else following along...

It was taking 13 seconds to combine two small (5 line) emails with formatting. I decided to try combining some larger emails to see what would happen. The script ran for a minute or two and then the AppleScript timer timed out and left OmniFocus in a hung state that needed a force quit. After that I also had to cancel a sync that was hanging. No damage was done, but it's clear that using that particular script should be avoided. The plaintext version does work well though when unformatted text is acceptable.
 
A slight redraft of the format-preserving version. (Gives a slightly cleaner output).

Takes about two seconds to merge three tasks and their notes on my system, but it sounds as if this kind of code may be prohibitively slow with some systems or some data ...

Code:
tell application id "com.omnigroup.omnifocus"
	tell content of front document window of front document
		set lstTasks to value of selected trees where (class of its value is task or class of its value is inbox task)
		if length of lstTasks < 2 then return
		set oFirstTask to first item of lstTasks
		set lstRest to items 2 thru end of lstTasks
		
		tell oFirstTask -- INSERT TITLE OF FIRST TASK AT START OF ITS OWN NOTE
			set refNote to a reference to note
			insert name & ":
" at before words of refNote
			set refLast to a reference to last character of refNote
			duplicate refLast to after refLast
			set last character of refNote to "
"
			repeat with oTask in lstRest -- APPEND TITLES AND NOTES OF OTHER TASKS TO NOTE OF FIRST TASK
				duplicate refLast to after refLast
				insert ("
" & (name of oTask) as string) & ":
" at before last character of refLast
				delete refLast
				duplicate (paragraphs of note of oTask) to after (refLast)
				set last character of refNote to "
"
				delete oTask
			end repeat
		end tell
	end tell
end tell

Last edited by RobTrew; 2011-03-01 at 11:18 AM..
 
Very nice! I ran a test and it only took a few seconds to combine a couple formatted emails.
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
combining planning view and context view Gizmo OmniFocus 1 for Mac 7 2011-11-23 12:47 PM
Combining lines stevechamp OmniGraffle General 1 2007-12-17 01:38 AM
Dividing and combining rows Harvey Leff OmniOutliner 3 for Mac 1 2007-11-25 11:41 AM
Combining two OmniFocus documents? jasong OmniFocus 1 for Mac 3 2007-07-03 02:42 PM
Combining shapes - masking, cutout, cutaway, compositing… chirsten OmniGraffle Extras 0 2006-11-22 03:17 PM


All times are GMT -8. The time now is 05:05 AM.


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