OmniFocus – Icons in Quick Entry Window

Description

Earlier today, I saw a tweet from Dean Holmes wishing aloud that OmniFocus would add "informational icons" to certain tasks. (In Dean's case to denote the emails he clipped from Mail.app)

One approach that Dean could take here would be to write a script which moves items from Mail into a Quick Entry window and then automatically adds in an "Email Icon" to the task name. To me, though, it seems excessive to basically duplicate Omni's excellent Clip-O-Tron plug-in for Mail just to add a single icon to a task name. And besides -- What if he wanted to use other icons in the Quick Entry Window? Or what if he wanted to use them for stuff other than Mail messages?

Maybe it could be a sort of "heads-up display" which allows you to append often-used icons or text directly into the Quick Entry window? This seemed like it could be a fun little script project -- and one that people could tweak in some creative ways (or even add to existing OmniFocus AppleScripts).

So I rolled up my sleeves and came up with this...

INSTRUCTIONS

When run, the script presents you with a simple, three-button dialog box . Each button has an icon and a description. Press the button for the icon you want and it is added to the beginning of the Tasks's name in the Quick Entry window.

This AppleScript will work when run from the AppleScript Editor, as an app, or from a "Keyboard Launcher App" like FastScripts or Alfred. Personally, I think running this from a keyboard launcher makes the most sense. It's fast and, in the spirit of the Quick Entry Window, it keeps you focused -- quite literally -- on the task at hand. (Alfred users can download an Alfred extension for the script here.)

An example: You select an item in Mail.app and use the OmniFocus Clip-O-Tron shortcut to push the message into the Quick Entry Window. Once you see your item there, just activate the script and select which icon you'd like to add to your task. You'll see it added to the beginning of the task and it's now ready to be saved into OmniFocus.

Note -- Due to the idiosyncratic nature of AppleScript, I couldn't give you three icon choices and also a "Cancel" button. I decided that "more choice" was the way I wanted to go, so I added a bit of code which cancels the script if you don't choose an icon within 5 seconds. Like the icons themselves, you can customize this "time out" period if it's too fast/slow for you.

ICON / EMOJI CUSTOMIZATION

At the beginning of the script, you'll see three properties ("icon_1", "icon_2", and "icon_3"). If you'd like to change the default icons I've included, this is where you'll do so. Just paste your new icons or emoji where you see the existing ones and change the descriptions to match.

The Code

(*
◸ Veritrope.com
OmniFocus Quick Entry Icons
VERSION 1.01
May 24, 2014

// UPDATE NOTICES
     ** Follow @Veritrope on Twitter, Facebook, Google Plus, and ADN for Update Notices! **

// SUPPORT VERITROPE!
     If this AppleScript was useful to you, please take a second to show your love here:
     http://veritrope.com/support
     
// SCRIPT INFORMATION AND UPDATE PAGE
    http://veritrope.com/code/omnifocus-icons

// REQUIREMENTS
    More details on the script information page.

//CHANGELOG
    1.01 Update to use OmniFocus 2's App Icon, 10.9 Buttons.
    1.0 INITIAL RELEASE

// RECOMMENDED INSTALLATION INSTRUCTIONS:
    Just run the script while the Quick Entry window is open!

NOTE:
    For faster workflow, set up a keyboard shortcut and
    trigger the script with an application like FastScripts
    or Alfred (More details about this on the Script's Info Page).
*)


(*
======================================
// USER SWITCHES (YOU CAN CHANGE THESE!)
======================================
*)


-- YOU CAN CHANGE THE ICON CHOICES AND DESCRIPTIONS HERE!
property icon_1 : "✉" & tab & "MAIL"
property icon_2 : "☎" & tab & "PHONE"
property icon_3 : "✍" & tab & "WRITE"

(*
======================================
// MAIN PROGRAM
======================================
*)


-- ICON SELECTION MENU
tell application "System Events" to set the_Choice to display dialog ¬
    "Select An Icon to Add to Quick Entry
(Automatically Cancels in 5 Seconds)"
giving up after 5 buttons {icon_1, icon_2, icon_3} ¬
    with title ¬
    "Veritrope.com | Quick Entry Icons" with icon path to resource "AppIcon.icns" in bundle (path to application "OmniFocus")

-- CANCEL SCRIPT BY WAITING 5 SECONDS, OR…
if gave up of the_Choice is true then
    return
else
   
    -- ADD THE ICON TO THE QUICK ENTRY WINDOW
    set the_Button to button returned of the_Choice
    set the_Icon to first character of the_Button
    tell application "OmniFocus"
        try
            set omni_Selection to name of inbox task 1 of quick entry
            set the_Icon to the_Icon & space as string
            set adj_Text to the_Icon & omni_Selection
            set name of inbox task 1 of quick entry to adj_Text
        end try
    end tell
end if