This, however, is a version which places formatted RTF rather than plain text in the clipboard.
You can edit the CSS lines near the beginning to alter the details of point size, font, and color.
You can edit the CSS lines near the beginning to alter the details of point size, font, and color.
Code:
property pTitle : "Selected actions to RTF clipboard" property pVer : "0.6" -- Uses table format to align labels and allow wrapping of note. property pblnIncludeNotes : true property pTaskLabel : "Action Item:" property pDueLabel : "Due by:" property pProjLabel : "Project:" property pContextLabel : "Who:" -- or "Context: " edit as required property pNoteLabel : "Note:" -- edit font, point size, color, margins etc as required: property pstrCSS : " .TaskLabel {color:#617794;} .DueLabel {color:#617794;} .ProjectLabel {color:#617794;} .ContextLabel {color:#617794;} .NoteLabel {color:#617794; } .Task {color:#3c6ba9; font-weight: bold;} .Due {color:#3c6ba9;} .Project {color:#3c6ba9;} .Context {color:#ff0000;} .Note {color: #666666} td {font: 14.0px 'Lucida Grande';} " tell application id "com.omnigroup.omnifocus" set oDoc to front document tell content of front document window of oDoc set lstActions to value of (selected trees where class of value is task or class of value is inbox task) set lngActions to count of lstActions if lngActions < 1 then tell application id "com.apple.systemevents" activate display dialog "Select one or more (non-inbox) actions and run this script" buttons {"OK"} default button "OK" with title pTitle end tell return end if set str to "" repeat with oAction in lstActions set {strName, dteDue, oProject, oContext, strNote} to {name, due date, containing project, its context, note} of oAction set str to str & "<table border=\"0\" cellpadding=\"2\">" set str to str & "<tr><td WIDTH=100 align=\"right\" style=\"vertical-align:top\"><span class=\"TaskLabel\">" & ¬ pTaskLabel & "</span></td><td WIDTH=500><span class=\"Task\">" & strName & "</span></td></tr>" if dteDue is not missing value then set str to ¬ (str & "<tr><td align=\"right\" style=\"vertical-align:top\"><span class=\"DueLabel\">" & pDueLabel & ¬ "</span></td><td><span class=\"Due\">" & dteDue as string) & "</span></td></tr>" if oProject is not missing value then set str to ¬ str & "<tr><td align=\"right\" style=\"vertical-align:top\"><span class=\"ProjectLabel\">" & ¬ pProjLabel & "</span></td><td><span class=\"Project\">" & name of oProject & "</span></td></tr>" if oContext is not missing value then set str to ¬ str & "<tr><td align=\"right\" style=\"vertical-align:top\"><span class=\"ContextLabel\">" & pContextLabel & ¬ "</span></td><td><span class=\"Context\">" & name of oContext & "</span></td></tr>" else set lstContexts to name of (flattened contexts of oDoc) tell application id "com.apple.systemevents" -- (needed for interactivity when launched by osascript, Keyboard Maestro etc) activate set varChoice to choose from list lstContexts with prompt ¬ "Assign a context to:" & return & return & strName ¬ default items {first item of lstContexts} ¬ cancel button name "No context needed" with title pTitle end tell if varChoice is not false then set strContext to first item of varChoice set context of oAction to (first flattened context of oDoc where name = strContext) set str to str & "<tr><td align=\"right\" style=\"vertical-align:top\"><span class=\"ContextLabel\">" & pContextLabel & ¬ "</span></td><td><span class=\"Context\">" & strContext & "</span></td></tr>" end if end if if pblnIncludeNotes then if length of strNote > 0 then ¬ set str to str & "<tr><td align=\"right\" style=\"vertical-align:top\"><span class=\"NoteLabel\">" & ¬ pNoteLabel & "</span></td><td><span class=\"Note\">" & strNote set str to str & "</td></tr></table>" set str to str & "<p><p>" end repeat end tell end tell set strPara to "<p>" & str & "</p>" set strHTML to " <html><head><style type=\"text/css\"> " & pstrCSS & " </style></head><body>" & strPara & "</body></html>" if length of str > 0 then do shell script "echo " & quoted form of strHTML & " | textutil -format html -convert rtf -stdin -stdout | pbcopy -Prefer rtf" set str to do shell script "echo " & quoted form of strHTML & " | textutil -format html -convert txt -stdin -stdout" my Growl(lngActions) end if -- Replace a sub string on replaceString(theText, oldString, newString) set AppleScript's text item delimiters to oldString set tempList to every text item of theText set AppleScript's text item delimiters to newString set theText to the tempList as string set AppleScript's text item delimiters to "" return theText end replaceString on Growl(lngActions) -- If Growl is running, report the references sent if lngActions > 0 then if lngActions = 1 then set strRefInflection to " action" else set strRefInflection to " actions" end if set strReport to "Formatted versions of " & (lngActions as string) & strRefInflection & " in RTF clipboard." tell application "System Events" set blnGrowlRunning to (count of (every process whose name is "GrowlHelperApp")) > 0 if blnGrowlRunning then -- set strReport to text 1 thru ((length of strReport) - 2) of strReport tell application "GrowlHelperApp" register as application "RobTrew scripts" all notifications {"Actions handled"} default notifications {"Actions handled"} icon of application "OmniFocus" notify with name "Actions handled" title "Actions processed" application name "RobTrew scripts" description strReport end tell else activate display dialog strReport buttons {"OK"} default button "OK" with title pTitle end if end tell end if end Growl
Last edited by RobTrew; 2011-03-25 at 06:16 AM.. Reason: Ver 0.6 Uses Growl to report result