The Omni Group Forums

The Omni Group Forums (
-   OmniFocus Extras (
-   -   AS to replace the Clip-O-Tron (

ptorngaard 2010-03-15 02:48 AM

AS to replace the Clip-O-Tron
I'm working on a AS that can replace Clip-o-tron until the nice people at OmniGroup have worked out a more useful replacement.

Steps in the script are simple:[LIST=1][*]Get the selected email[*]Get the text for the mail[*]Compile a 'message:MessageID'[*]Get subject as subject for the OF Document[*]Insert both in the note field of the OF document[*]Open Quick Note with the compiled data[*]Ask Mail to move the message out of Inbox to an 'Action Folder'[/LIST]
:confused: My challenge right now is to verify that OF have added the document before asking Mail to file the message elsewhere. So if any of you friendly OF users has suggestions. AS snippets are more than welcome I'll be brushing up the final script and posting it here.

xmas 2010-03-15 08:04 AM

If you publish your script I can take a look at it...

Also, what OS are you on? And what exactly isn't working about the Clip-o-tron for you?

ptorngaard 2010-03-15 11:43 PM

The reason that I'm working on a replacement for Clip-o-tron is due to it's limitations within Mail actions. I'd like in one workflow to be able to both send the email to an archive within Mail and at the same time post a link and text in OF. If Clip-o-tron could be instructed to do different actions depending on 'shortcuts' or small AS snippets I be dropping my version right away.

Here is the AppleScript. The code is still preliminary - I'm learning AS at the same time. Would like to be able to both handle Actions and Waiting for in the same workflow - depending on the Context selected in the Quick Note.


set MAIL_ACTION_TARGET to "Action"

tell application "Mail"
set these_selections to selection
set the current_mail to item 1 of the these_selections
set theSubject to subject of current_mail

set umid to message id of the current_mail
set encodedURI to urlencode(umid) of me
set mail_URI to "message://%3C" & encodedURI & "%3E"

set taskTitle to theSubject
set mail_body to content of the current_mail
set note_content to "Original massge is: " & mail_URI & return & return & return & "Sender: " & (sender of the current_mail) & return & mail_body
on error
log "No message selected"
end try

-- Send the email straight to OmniFocus for more processing
tell application "OmniFocus"
tell default document
tell quick entry
set newTask to make new inbox task with properties {name:taskTitle, note:note_content}
select {inbox task 1}
end tell
on error
log "error"
end try

-- Test and see if the enty made it to Inbox, this is to prevent Mail from moving
-- messages that have not been filed in OF

end tell
end tell

-- Move the mail to the mailbox that have been defined as the default target for actions

tell application "Mail"
move current_mail to mailbox MAIL_ACTION_TARGET
end tell

end tell
Code snippet extracted from Waiting-For-Mails-to-OmniFocus.scpt

Waiting For Mails to OmniFocus Script
by, Sven Fechner

on urlencode(theText)
set theTextEnc to ""
repeat with eachChar in characters of theText
set useChar to eachChar
set eachCharNum to ASCII number of eachChar
if eachCharNum = 32 then
set useChar to "+"
else if (eachCharNum ≠ 42) and (eachCharNum ≠ 95) and (eachCharNum < 45 or eachCharNum > 46) and (eachCharNum < 48 or eachCharNum > 57) and (eachCharNum < 65 or eachCharNum > 90) and (eachCharNum < 97 or eachCharNum > 122) then
set firstDig to round (eachCharNum / 16) rounding down
set secondDig to eachCharNum mod 16
if firstDig > 9 then
set aNum to firstDig + 55
set firstDig to ASCII character aNum
end if
if secondDig > 9 then
set aNum to secondDig + 55
set secondDig to ASCII character aNum
end if
set numHex to ("%" & (firstDig as string) & (secondDig as string)) as string
set useChar to numHex
end if
set theTextEnc to theTextEnc & useChar as string
end repeat
return theTextEnc
end urlencode[/CODE]

All times are GMT -8. The time now is 01:33 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.