EvanLovely
5/30/2014 - 10:00 PM

Select items in OmniFocus, Run Script, and have [Sticky Notifications](http://instinctivecode.com/sticky-notifications/) Mac App put up noti

Select items in OmniFocus, Run Script, and have Sticky Notifications Mac App put up notifications that are clickable back to OmniFocus task.

(*
OmniFocus to Sticky Notifications 2.0
 
This script will take the selected tasks (or projects as well) in OmniFocus and create indiviual reminders in Sticky Notifications. Feel free to change the "title" part of the URL from "OmniFocus" to whatever you like.
 
Copyright 2012 -- [Brandon Pittman](http://brandonpittman.net)

Turn Omnifocus Tasks Into Sticky Notifications with AppleScript: 
http://brandonpittman.net/2012/11/turn-omnifocus-tasks-into-sticky-notifications-with-applescript/

(updates: works from OmniFocus toolbar; preserves prior text item delimiters; proper caps for OmniFocus :) -[dan](http://bylr.net/3/))

(updates: 2014-05-30 Added clickable links in notification that takes you to OmniFocus task - From [Evan Lovely](http://evanlovely.com) [here](https://gist.github.com/EvanLovely/da4878cc8b1da47d1f73)
*)

tell application "OmniFocus"
	set theWindow to front document window of front document
	set theTasks to selected trees of content of theWindow
end tell

repeat with singleTask in theTasks
	tell singleTask
		set ti to name
		set taskID to id
		set taskLink to " omnifocus:///task/" & taskID
	end tell
	urlEncode(ti)
	urlEncode(taskLink)
	tell application "System Events"
		
		open location "sticky-notifications://note?title=OmniFocus&message=" & ti & taskLink
	end tell
end repeat


on urlEncode(str)
	local str
	try
		return (do shell script "/bin/echo " & quoted form of str & ¬
			" | perl -MURI::Escape -lne 'print uri_escape($_)'")
	on error eMsg number eNum
		error "Can't urlEncode: " & eMsg number eNum
	end try
end urlEncode