If anybody's interested, I made two minor changes to the (modified) script:
1) removed the "cancel" button from the dialog because it's not necessary (plus, clicking it gives an error)
2) the total time (in minutes) is added to the clipboard. When pasted into omnifocus, this number takes the appearance of "__h __m" like you'd expect
Code:
-- Sum estimated times, display sum in Growl and copy sum to clipboard (for later pasting back into estimated time for an entire project, or elsewhere).
-- Jake Bowers (jwb1970@gmail.com), 2008-24-10
-- largely based on RobTrew's StartTimer.scpt Ver 0.02 for code to adds up durations of selected tasks (http://forums.omnigroup.com/showthread.php?t=4748)
-- and on hint from a11en in thread Minuteur Applescript for Growl Notification. (http://forums.omnigroup.com/showthread.php?t=6749)
-- James O'Leary (jpo@me.com), 2008-08-11
-- now can handle context view "boxes) (assigned an estimated time of 0) and the time displayed is in hours and minutes instead of
-- just a straight up hours number. Displays in dialog box now instead of copying to clipboard. Item count displayed as well.
-- Aaron Hunyady (aaron@hunyady.net), 2009-08-01
-- Removed "cancel" button in dialog. Total time in minutes is copied to the clipboard.
tell application "OmniFocus"
tell front document
tell document window 1
set oTrees to selected trees of content
set lngTrees to count of oTrees
if lngTrees > 0 then
set lngTotal to 0
repeat with iTree from 1 to lngTrees
set oTask to value of (item iTree of oTrees)
try
set lngMinutes to estimated minutes of oTask
on error
set lngMinutes to 0
end try
if lngMinutes as string is equal to "missing value" then
set lngMinutes to 0
end if
set lngTotal to lngTotal + lngMinutes
--do shell script "/usr/local/bin/growlnotify OmniFocus -m 'Total time " & lngTotal & " minutes' -p 1"
end repeat
end if
set the clipboard to lngTotal as rich text
end tell
end tell
set lngHours to 0
repeat
if lngTotal < 60 then exit repeat
set lngTotal to lngTotal - 60
set lngHours to lngHours + 1
end repeat
end tell
if lngHours = 1 then
set strPluralHours to " hour "
else
set strPluralHours to " hours "
end if
if lngMinutes = 1 then
set strPluralMinutes to " minute."
else
set strPluralMinutes to " minutes."
end if
display dialog "Item count: " & lngTrees & "
" & "Total time: " & (lngHours) & strPluralHours & lngTotal & strPluralMinutes buttons {"OK"} default button 1