Guest
2011-02-12, 10:41 AM
OK - not one of my scripts - I need to consult Eric Böhnisch-Volkmann about the terms under which he would be happy for a modified version of his script to be posted.
In the meanwhile, here is how you might finish off a script to do that:
Code:
-- Add new to do to OmniFocus
try
tell application id "com.omnigroup.OmniFocus"
if theDelayValue ≥ 0 then
tell default document to set newTask to make new inbox task with properties {name:theSummary, due date:theDueDate}
else
tell default document to set newTask to make new inbox task with properties {name:theSummary}
end if
end tell
my PasteToNote(newTask, theSummary, theURL)
on error errmsg
display alert (localized string "OmniFocus is not available.")
end try
on error errmsgs
display alert (localized string "Error when adding item to OmniFocus") message errmsg
end try
on PasteToNote(oObj, strLegend, strURL)
set strHTML to quoted form of ("<font face=\"Helvetica\"><a href=\"" & strURL & "\">" & strLegend & "</a></font>")
do shell script "echo " & strHTML & " | textutil -format html -convert rtf -stdin -stdout | pbcopy -Prefer rtf"
tell application id "com.omnigroup.OmniFocus"
set cClass to class of oObj
if not (cClass is in {task, inbox task, project}) then return
tell front document window of front document
if selected view mode identifier ≠ "project" then set selected view mode identifier to "project"
if cClass is inbox task then
tell tree 1 of sidebar -- Inbox
if not selected then set selected to true
end tell
else
if (focus as list) ≠ {} then set focus to {}
tell tree 2 of sidebar -- Library
if not selected then set selected to true
end tell
end if
tell content to select {oObj}
end tell
activate
end tell
tell application id "com.apple.systemevents"
keystroke "'" using {command down} -- Edit note
keystroke "v" using {command down} -- Paste
end tell
end PasteToNote
Last edited by RobTrew; 2011-02-12 at 04:31 PM..