Skip to content

Instantly share code, notes, and snippets.

@matellis
Last active July 18, 2017 01:35
Show Gist options
  • Save matellis/9924583 to your computer and use it in GitHub Desktop.
Save matellis/9924583 to your computer and use it in GitHub Desktop.
Sends the selected message from Airmail to Omnifocus 2
(*
Send currently selected Airmail message to OmniFocus 2 quick entry box, then archive it.
Based on http://simplicitybliss.com/add-last-sent-email-to-omnifocus
and http://discourse.omnigroup.com/t/mail-to-quick-entry-applescript/500
To install:
- Create a new Automator Service
- Cut/paste this into it
- Edit properties to your satisfaction
- Save as "Send to Omnifocus"
- Create a keyboard shortcut in Preferences (I use F6) to link to a hot key
Enjoy!
*)
-- Open OmniFocus Quick Entry window (true) or add the task silently to the OmniFocus Inbox (false)?
property ShowQuickEntry : true
-- Archive the message or not?
property ArchiveMessage : true
-- When showing the quick entry box, leave the cursor in the note instead of the subject?
property PutCursorInNote : false
try
tell application "AirMail Beta"
set message_subject to the subject of the selected message
set message_url to the selectedMessageUrl
if ArchiveMessage then
tell application "AirMail Beta"
activate
tell application "System Events" to tell process "Airmail Beta" to keystroke "e"
end tell
end if
tell application "OmniFocus"
if ShowQuickEntry then
tell quick entry
make new inbox task with properties {name:message_subject, note:message_url}
open
activate
end tell
tell application "System Events"
if PutCursorInNote then
keystroke (ASCII character 31)
keystroke "'" using command down
keystroke (key code 123)
else
keystroke (ASCII character 31)
keystroke "e" using command down
end if
end tell
else
tell default document to make new inbox task with properties {name:message_subject, note:message_url}
end if
end tell
end tell
end try
@matthewwoo-zz
Copy link

Hey this works like a charm when I run it manually in the automator, but when I try to assign a hot key, it doesn't work.

Any ideas why?

@DennisMeek
Copy link

I'm new to Automator and Apple Script. Can you recommend a tutorial video and website to help me get started?

@peterdesaulniers
Copy link

@matthewwoo, be sure to set 'Services receives' to 'no input'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment