<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"><channel><title>Disruptive Library Technology Jester &#187; applescript</title> <atom:link href="http://dltj.org/tag/applescript/feed/" rel="self" type="application/rss+xml" /><link>http://dltj.org</link> <description>We&#039;re Disrupted, We&#039;re Librarians, and We&#039;re Not Going to Take It Anymore</description> <lastBuildDate>Mon, 06 Feb 2012 20:04:22 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <cloud domain='dltj.org' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' /> <creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/us/</creativeCommons:license> <item><title>The PERL Way to Add OmniFocus Inbox Entries from Twitter</title><link>http://dltj.org/article/twitter-to-omnifocus/</link> <comments>http://dltj.org/article/twitter-to-omnifocus/#comments</comments> <pubDate>Wed, 20 Oct 2010 02:09:16 +0000</pubDate> <dc:creator>Peter Murray</dc:creator> <category><![CDATA[Raw Technology]]></category> <category><![CDATA[applescript]]></category> <category><![CDATA[Getting Things Done]]></category> <category><![CDATA[howto]]></category> <category><![CDATA[OmniFocus]]></category> <category><![CDATA[perl]]></category> <category><![CDATA[Twitter]]></category> <category><![CDATA[twitter-to-omnifocus]]></category><guid isPermaLink="false">http://dltj.org/?p=1734</guid> <description><![CDATA[Over the weekend I got the bright idea of asking OmniGroup to ask an iPhone voice recognition application (like Dragon Dictation) to add a link to the OmniFocus iPhone application. That way I could simply dictate new inbox items on &#8230; <a href="http://dltj.org/article/twitter-to-omnifocus/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<abbr class="unapi-id ignore noPrint" title="http://dltj.org/?p=1734"></abbr><p>Over the weekend I got the bright idea of asking <a href="http://www.omnigroup.com/" title="The Omni Group">OmniGroup</a> to ask an iPhone voice recognition application (like <a href="http://itunes.apple.com/us/app/dragon-dictation/id341446764?mt=8" title="Dragon Dictation for iPhone, iPod touch, and iPad on the iTunes App Store">Dragon Dictation</a>) to add a link to the <a href="http://www.omnigroup.com/products/omnifocus_for_iphone/" title="OmniFocus for iPhone - Products - The Omni Group">OmniFocus iPhone</a> application.  That way I could simply dictate new inbox items on the iPhone rather than laboriously typing them with the on-screen keyboard.  Before making the suggestion, I <a href="http://forums.omnigroup.com/search.php?do=process&amp;quicksearch=1&amp;childforums=1&amp;exactname=1&amp;s=&amp;securitytoken=guest&amp;query=voice+recognition&amp;showposts=0" title="The Omni Group Forums - Search Forums">searched the OmniFocus User Forum for &#8220;voice recognition&#8221;</a> to see if anyone else had suggested the same thing.  As it turns out, there were <a href="http://forums.omnigroup.com/showthread.php?t=5871" title="Ubiqutious task entry -- anywhere, anytime - The Omni Group Forums">a</a> <a href="http://forums.omnigroup.com/showthread.php?t=11543&amp;highlight=voice+recognition" title="Voice -&gt; OmniFocus - The Omni Group Forums">few</a> <a href="http://forums.omnigroup.com/showthread.php?t=11544&amp;highlight=voice+recognition" title="new solution to speak new inbox tasks - The Omni Group Forums">posts</a> that had instructions from people using Twitter as an intermediary.  Unfortunately, they either required a desktop Twitter client to be running all of the time or <a href="http://ptone.com/dablog/2009/03/voice-to-omnifocus-revisited/" title="Voice to OmniFocus, revisited">used</a> the now deprecated BasicAuth-based Twitter authentication scheme.  So I created my own.<br /><span id="more-1734"></span><br /><h2>The Script</h2><br />I&#8217;m a UNIX command line geek at heart, and an old one at that, so my preferred language is Perl. This program runs as a background command line application using a couple of Perl modules: <a href="http://search.cpan.org/dist/Net-Twitter-Lite/" title="Marc Mims / Net-Twitter-Lite - search.cpan.org">Net::Twitter::Lite</a> to interact with Twitter and <a href="http://search.cpan.org/~dsugal/Mac-AppleScript/" title="Dan Sugalski / Mac-AppleScript - search.cpan.org">Mac::AppleScript</a> to interact with OmniFocus.  Install those two modules and their depencencies on your Mac if you don&#8217;t already have them (e.g. <code>cpan install Net::Twitter::Lite</code> and <code>cpan install Mac::AppleScript</code>), then copy <a href="http://github.com/dltj/twitter-to-omnifocus/raw/master/twitter-to-omnifocus" title="twitter-to-omnifocus script">this script</a> and a configuration file based on <a href="http://github.com/dltj/twitter-to-omnifocus/raw/master/tweettoOmniFocus.cfg.example" title="tweettoOmniFocus.cfg example">this sample</a> in a directory off your home directory.  The <a href="http://github.com/dltj/twitter-to-omnifocus" title="dltj's twitter-to-omnifocus at master - GitHub">source code</a> is available on GitHub if you want to fork it and improve it.</p><p><h2>Registering your Application with Twitter</h2><br /><div id="attachment_1735" class="wp-caption alignright" style="width: 310px;  border: 1px solid #dddddd; background-color: #f3f3f3; padding-top: 4px; margin: 10px; text-align:center; float: right;"><a href="http://cdn.dltj.org/wp-content/uploads/2010/10/Tweet-Privacy.png"><img src="http://cdn.dltj.org/wp-content/uploads/2010/10/Tweet-Privacy-300x71.png" alt="" title="Tweet Privacy" width="300" height="71" class="size-medium wp-image-1735" /></a><p style=' padding: 0 4px 5px; margin: 0;'  class="wp-caption-text">Tweet Privacy Checkbox</p></div>To put Twitter in the middle between my iPhone voice recognition app and OmniFocus, I set up a new Twitter account just for the purpose of pushing entries into the OmniFocus Inbox.  I marked this new account as <a href="http://support.twitter.com/groups/31-twitter-basics/topics/107-my-profile-account-settings/articles/14016-about-public-and-protected-accounts" title="Twitter Help Center">private in the account settings</a> because I don&#8217;t want anyone subscribing to the tweets sent through this account.</p><p>Because I marked it as private, the script can&#8217;t read the home timeline of tweets without authentication.  In order to authenticate with Twitter, I need to <a href="http://dev.twitter.com/apps" title="http://dev.twitter.com/apps" class="broken_link" rel="nofollow">register the script</a> with the Twitter API service to get a &#8220;Consumer Key&#8221; and a &#8220;Consumer Secret&#8221;.  The registration page looks similar to below, but you&#8217;ll need to pick a different name.  (Application names must be unique across Twitter.)<br /><div id="attachment_1737" class="wp-caption aligncenter" style="width: 805px;  border: 1px solid #dddddd; background-color: #f3f3f3; padding-top: 4px; margin: 10px; text-align:center; display: block; margin-right: auto; margin-left: auto;"><a href="http://cdn.dltj.org/wp-content/uploads/2010/10/New-Twitter-Application-dev.twitter.com_1287524992428.png"><img src="http://cdn.dltj.org/wp-content/uploads/2010/10/New-Twitter-Application-dev.twitter.com_1287524992428-795x1024.png" alt="" title="New Twitter Application screen for twitter-to-omnifocus" width="795" height="1024" class="size-large wp-image-1737" /></a><p style=' padding: 0 4px 5px; margin: 0;'  class="wp-caption-text">New Twitter Application screen for twitter-to-omnifocus</p></div></p><p>After submitting that form, you&#8217;ll see a page that will have your key information.  Replace the sample keys in the tweettoOmniFocus.cfg file with the ones from this page.</p><p>You&#8217;ll need to run the twitter-to-omnifocus application once interactively on the command line in order to complete the process of registering the script with Twitter.  First, change the mode of the script so that you can execute it, then run the script:</p><pre>  chmod u+x twitter-to-omnifocus</pre><pre>  ./twitter-to-omnifocus</pre><p>You&#8217;ll be promted to go to a website to get a PIN:</p><pre>  Authorize this app at http://twitter.com/oauth/authorize?oauth_token=nnn and enter the PIN#</pre><p>When you get the PIN, paste it into the terminal window and hit return.  Two new security tokens will be added to the configuration file.</p><p><h2>Getting the Script to Run Periodically on the Mac</h2><br />The last step is to get the script to run periodically on the Mac.  If one were to stick to UNIX traditions, you would run `crontab -e` to create a cron entry.  I think that would work, but the Mac-way of doing it is to create a launchd entry.  You can create one of these by hand, but I find using <a href="http://sourceforge.net/projects/lingon/" title="Lingon | SourceForge.net">Lingon</a> to be a much more palatable way of doing it.  (Okay &#8212; so I&#8217;m not a pure command-line junkie.)<br /><div id="attachment_1738" class="wp-caption aligncenter" style="width: 724px;  border: 1px solid #dddddd; background-color: #f3f3f3; padding-top: 4px; margin: 10px; text-align:center; display: block; margin-right: auto; margin-left: auto;"><a href="http://cdn.dltj.org/wp-content/uploads/2010/10/Lingon-configuration-for-twitter-to-omnifocus.jpg"><img src="http://cdn.dltj.org/wp-content/uploads/2010/10/Lingon-configuration-for-twitter-to-omnifocus.jpg" alt="" title="Lingon configuration for twitter-to-omnifocus" width="714" height="732" class="size-full wp-image-1738" /></a><p style=' padding: 0 4px 5px; margin: 0;'  class="wp-caption-text">Lingon configuration for twitter-to-omnifocus</p></div></p><p><h2>All Done!</h2><br /><div id="attachment_1742" class="wp-caption alignright" style="width: 210px;  border: 1px solid #dddddd; background-color: #f3f3f3; padding-top: 4px; margin: 10px; text-align:center; float: right;"><img src="http://cdn.dltj.org/wp-content/uploads/2010/10/IMG_0054-200x300.png" alt="" title="Dragon Dictation Screen" width="200" height="300" class="size-medium wp-image-1742" /><p style=' padding: 0 4px 5px; margin: 0;'  class="wp-caption-text">iPhone Dragon Dictation screen</p></div>With that set, you can now simply send a tweet to your private Twitter account from any mechanism you might have.  What got me started on this path was using <a href="http://itunes.apple.com/us/app/dragon-dictation/id341446764?mt=8" title="Dragon Dictation for iPhone, iPod touch, and iPad on the iTunes App Store">Dragon Dictation</a> on the iPhone to dictate inbox items.  One person suggested using <a href="http://jott.com/default.aspx" title="Jott.com | Voice-to-Text Notes, To Dos &amp; Reminders.  Voicemail-to-Email and Text Message">Jott</a> for phone-to-Twitter transcribing and another suggested an <a href="http://tweetymail.com/" title="Twitter over Email">e-mail path</a>.</p><p>In the end, this is quite an effort and a moderately fragile setup for doing what I want.  In particular, the dictated entries don&#8217;t immediately appear in my iPhone OmniFocus app database. I&#8217;d like some tighter integration between the applications, but I&#8217;ll settle for this for now.<br /><br style="clear: both" /></p>]]></content:encoded> <wfw:commentRss>http://dltj.org/article/twitter-to-omnifocus/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> <item><title>Getting a Hyperlink of the Last Sent Message from Mail.app using Applescript</title><link>http://dltj.org/article/copy-last-sent-message-as-rtf-link/</link> <comments>http://dltj.org/article/copy-last-sent-message-as-rtf-link/#comments</comments> <pubDate>Thu, 15 May 2008 16:15:15 +0000</pubDate> <dc:creator>Peter Murray</dc:creator> <category><![CDATA[Raw Technology]]></category> <category><![CDATA[applescript]]></category> <category><![CDATA[email]]></category> <category><![CDATA[Getting Things Done]]></category> <category><![CDATA[Mac OS X Operating System]]></category> <category><![CDATA[OmniFocus]]></category><guid isPermaLink="false">https://dltj.org/?p=363</guid> <description><![CDATA[I&#8217;ve been a fan of Getting Things Done as a technique for managing projects, but it was only recently that I settled on OmniFocus as the &#8220;trusted system&#8221; collecting all of my next actions. One of the things I like &#8230; <a href="http://dltj.org/article/copy-last-sent-message-as-rtf-link/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<abbr class="unapi-id ignore noPrint" title="https://dltj.org/?p=363"></abbr><p>I&#8217;ve been a fan of <a href="http://en.wikipedia.org/wiki/Getting_Things_Done" title="Getting Things Done article in Wikipedia">Getting Things Done</a> as a technique for managing projects, but it was only recently that I settled on OmniFocus as the &#8220;trusted system&#8221; collecting all of my next actions.  One of the things I like about <a href="http://www.omnigroup.com/applications/omnifocus/" title="OmniFocus product information page">OmniFocus</a> &#8212; as a rich, Mac-only application &#8212; is its ability to hold links to messages from Mail.app as notes for each action.  This occurs, for instance, when you use the &#8220;Clippings&#8221; function of OmniFocus to create a new action based on the message that you are currently viewing in Mail.app.  (There are other ways to do it, such as the method described by <a href="http://www.earth2adam.com/omnifocus-gtd-actions-from-mail-redux/" title="OmniFocus GTD: Actions from Mail (redux)">Adam Sneller</a>.)</p><p>One of the things I find myself doing is creating actions in a &#8220;Waiting&#8221; context based on e-mail messages I&#8217;ve just sent.  Initially, I&#8217;d just create the action via the OmniFocus Quick Entry window.  But I found myself needing to refer back to the message I sent when the person I&#8217;m waiting on doesn&#8217;t come through.  So I started clicking and dragging the message from the Sent mailbox to the action.  But to do that I&#8217;d have to click into the Sent mailbox and have the Mail.app and the OmniFocus windows set up just right.  Or I&#8217;d have to follow a select-sent-mailbox, select-message, OmniFocus-quick-entry-with-clipping, select-Inbox, select-next-message workflow.  And that took time and effort.  So I&#8217;ve created an AppleScript ditty that does the work of creating a hyperlink on the clipboard of the last sent message.  The results can then be pasted into any RTF-aware application, including OmniFocus.<br /><span id="more-363"></span><br />The script is based heavily on <a href="http://www.tuaw.com/2008/04/14/speedy-creation-of-rich-text-links-to-mail-messages/" title="Speedy creation of rich text links to Mail messages">Speedy creation of rich text links to Mail messages</a> by <a href="http://www.tuaw.com/bloggers/brett-terpstra/" title="Posts by Brett Terpstra at The Unofficial Apple Weblog (TUAW)">Brett Terpstra</a>.  In particular, he had the missing link about creating RTF hyperlinks on the clipboard using a bash shell script.  The meat of the AppleScript is:</p><div class="wp_syntax"><div class="code"><pre class="applescript" style="font-family:monospace;"><span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Mail&quot;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">-- Ask the user which account to use</span>
	<span style="color: #ff0033; font-weight: bold;">set</span> _accts <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033; font-weight: bold;">get</span> accounts
	<span style="color: #ff0033; font-weight: bold;">set</span> _enabledAccounts <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span>
	<span style="color: #ff0033; font-weight: bold;">repeat</span> <span style="color: #ff0033; font-weight: bold;">with</span> eachAccount <span style="color: #ff0033; font-weight: bold;">in</span> _accts
		<span style="color: #808080; font-style: italic;">-- Only offer the enabled accounts for the user to choose</span>
		<span style="color: #ff0033; font-weight: bold;">if</span> enabled <span style="color: #ff0033; font-weight: bold;">of</span> eachAccount <span style="color: #ff0033; font-weight: bold;">then</span>
			<span style="color: #ff0033; font-weight: bold;">set</span> <span style="color: #ff0033;">the</span> <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">of</span> _enabledAccounts <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> eachAccount <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span>
		<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
	<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span>
	<span style="color: #ff0033; font-weight: bold;">set</span> _selectedAccount <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">choose <span style="color: #ff0033; font-weight: bold;">from</span> list</span> _enabledAccounts <span style="color: #ff0033; font-weight: bold;">with</span> title <span style="color: #009900;">&quot;Select Account&quot;</span> <span style="color: #ff0033; font-weight: bold;">with</span> prompt <span style="color: #009900;">&quot;Select the account from which to copy a link of the last sent message...&quot;</span> default <span style="color: #0066ff;">items</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">item</span> <span style="color: #000000;">1</span> <span style="color: #ff0033; font-weight: bold;">of</span> _enabledAccounts<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">-- Quit script if the user selected &quot;cancel&quot;</span>
	<span style="color: #ff0033; font-weight: bold;">if</span> _selectedAccount <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #0066ff;">false</span> <span style="color: #ff0033; font-weight: bold;">then</span>
		<span style="color: #ff0033; font-weight: bold;">return</span>
	<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
	<span style="color: #ff0033; font-weight: bold;">set</span> _selectedAccountName <span style="color: #ff0033; font-weight: bold;">to</span> _selectedAccount <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">-- Get the &quot;last&quot; message of the Sent mailbox of the selected account</span>
	<span style="color: #ff0033; font-weight: bold;">set</span> _msg <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">first</span> message <span style="color: #ff0033; font-weight: bold;">of</span> mailbox <span style="color: #009900;">&quot;Sent&quot;</span> <span style="color: #ff0033; font-weight: bold;">of</span> account _selectedAccountName
&nbsp;
	<span style="color: #808080; font-style: italic;">-- Get various properties of the message</span>
	<span style="color: #ff0033; font-weight: bold;">set</span> _date <span style="color: #ff0033; font-weight: bold;">to</span> _msg<span style="">'</span>s date sent
&nbsp;
	<span style="color: #ff0033; font-weight: bold;">try</span>
		<span style="color: #ff0033; font-weight: bold;">set</span> _recipient <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #ff0033;">first</span> recipient <span style="color: #ff0033; font-weight: bold;">of</span> _msg
		<span style="color: #ff0033; font-weight: bold;">set</span> _test <span style="color: #ff0033; font-weight: bold;">to</span> _recipient
	<span style="color: #ff0033; font-weight: bold;">on</span> <span style="color: #ff0033; font-weight: bold;">error</span>
		<span style="color: #808080; font-style: italic;">-- if the Recipient's name property was blank, use the e-mail address instead</span>
		<span style="color: #ff0033; font-weight: bold;">set</span> _recipient <span style="color: #ff0033; font-weight: bold;">to</span> address <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #ff0033;">first</span> recipient <span style="color: #ff0033; font-weight: bold;">of</span> _msg
	<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span>
&nbsp;
	<span style="color: #ff0033; font-weight: bold;">set</span> _sub <span style="color: #ff0033; font-weight: bold;">to</span> _msg<span style="">'</span>s subject
	<span style="color: #ff0033; font-weight: bold;">if</span> _sub starts <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #009900;">&quot;Re:&quot;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
		<span style="color: #808080; font-style: italic;">-- Remove the &quot;Re:&quot; prefix from messages</span>
		<span style="color: #ff0033; font-weight: bold;">set</span> _sub <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">text</span> <span style="color: #000000;">5</span> <span style="color: #ff0033;">through</span> <span style="color: #000000;">&#40;</span>length <span style="color: #ff0033; font-weight: bold;">of</span> _sub<span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">of</span> _sub
	<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
&nbsp;
	<span style="color: #ff0033; font-weight: bold;">set</span> _msgid <span style="color: #ff0033; font-weight: bold;">to</span> _msg<span style="">'</span>s message <span style="color: #0066ff;">id</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">-- Create the URL to the message</span>
	<span style="color: #ff0033; font-weight: bold;">set</span> _msglnk <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;message://%3C&quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">my</span> urlencode<span style="color: #000000;">&#40;</span>_msgid<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;%3E&quot;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">-- Create the anchor text for the link</span>
	<span style="color: #ff0033; font-weight: bold;">set</span> _anchorText <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;Message sent &quot;</span> <span style="color: #000000;">&amp;</span> _date <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; to &quot;</span> <span style="color: #000000;">&amp;</span> _recipient <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; regarding '&quot;</span> <span style="color: #000000;">&amp;</span> _sub <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;'&quot;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">-- Execute the external script to generate the RTF hyperlink on the clipboard</span>
	<span style="color: #0066ff;">do shell script</span> <span style="color: #009900;">&quot;/bin/bash -c <span style="color: #000000; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #000000;">&amp;</span> _script <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; <span style="color: #000000; font-weight: bold;">\\</span><span style="color: #000000; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #000000;">&amp;</span> _anchorText <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;<span style="color: #000000; font-weight: bold;">\\</span><span style="color: #000000; font-weight: bold;">\&quot;</span> <span style="color: #000000; font-weight: bold;">\\</span><span style="color: #000000; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #000000;">&amp;</span> _msglnk <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;<span style="color: #000000; font-weight: bold;">\\</span><span style="color: #000000; font-weight: bold;">\&quot;</span><span style="color: #000000; font-weight: bold;">\&quot;</span>&quot;</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span></pre></div></div><p>It first prompts the user for which account to use based on the list of active accounts.  Then it gets the last message in the Sent mailbox of that account, gets various metadata properties, and sends the results to the bash shell script.  The shell script comes from Brett; it creates the RTF snippet and pipes it into &#8216;<a href="http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/pbcopy.1.html" title="Mac OS X<br /> Manual Page For pbcopy(1)">pbcopy</a>&#8216; to put it on the clipboard:</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># Places a rich text link on the clipboard</span>
<span style="color: #666666; font-style: italic;"># usage: rtflink.sh &quot;Title of link&quot; &quot;URL to link to&quot;</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># This will paste *nothing* into applications that don't recognize rich text</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;{<span style="color: #000099; font-weight: bold;">\r</span>tf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf270
{<span style="color: #000099; font-weight: bold;">\f</span>onttbl<span style="color: #000099; font-weight: bold;">\f</span>0<span style="color: #000099; font-weight: bold;">\f</span>swiss<span style="color: #000099; font-weight: bold;">\f</span>charset0 Helvetica;}
{\colortbl;<span style="color: #000099; font-weight: bold;">\r</span>ed255\green255\blue255;}
\margl1440\margr1440<span style="color: #000099; font-weight: bold;">\v</span>ieww9000<span style="color: #000099; font-weight: bold;">\v</span>iewh8400<span style="color: #000099; font-weight: bold;">\v</span>iewkind0
\pard<span style="color: #000099; font-weight: bold;">\t</span>x720<span style="color: #000099; font-weight: bold;">\t</span>x1440<span style="color: #000099; font-weight: bold;">\t</span>x2160<span style="color: #000099; font-weight: bold;">\t</span>x2880<span style="color: #000099; font-weight: bold;">\t</span>x3600<span style="color: #000099; font-weight: bold;">\t</span>x4320<span style="color: #000099; font-weight: bold;">\t</span>x5040<span style="color: #000099; font-weight: bold;">\t</span>x5760<span style="color: #000099; font-weight: bold;">\t</span>x6480<span style="color: #000099; font-weight: bold;">\t</span>x7200<span style="color: #000099; font-weight: bold;">\t</span>x7920<span style="color: #000099; font-weight: bold;">\t</span>x8640\ql\qnatural\pardirnatural
{<span style="color: #000099; font-weight: bold;">\f</span>ield{\*<span style="color: #000099; font-weight: bold;">\f</span>ldinst{HYPERLINK <span style="color: #000099; font-weight: bold;">\&quot;</span>$2<span style="color: #000099; font-weight: bold;">\&quot;</span>}}{<span style="color: #000099; font-weight: bold;">\f</span>ldrslt 
<span style="color: #000099; font-weight: bold;">\f</span>0<span style="color: #000099; font-weight: bold;">\f</span>s24 \cf0 $1}}}&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> pbcopy <span style="color: #660033;">-Prefer</span> rtf</pre></div></div><p>The end result is a hyperlink with an anchor that looks something like:</p><pre>    Message sent Thursday, May 15, 2008 8:36:33 AM to Jane Partner regarding 'Can you pick up milk?'</pre><p>&#8230;waiting on the clipboard to be pasted into an action note.  With that bound to <span class="removed_link" title="http://docs.blacktree.com/quicksilver/triggers">a keyboard trigger via QuickSilver</span>, copying a link to a message is now a simple matter of keystrokes.</p><p>If you are interested, you can <a href="http://cdn.dltj.org/wp-content/uploads/2008/05/copy-last-sent-message-as-rtf-link.zip">download the &#8220;Copy last sent message as RTF link&#8221; AppleScript bundle</a> and try it yourself.  Let me know what you think.</p><p>Update 20080516T1219 : I had to modify the part of the code that gets the recipient name or (for recipients without name parts) the e-mail address.  The downloaded version has been updated.</p><p>Update 20110405T1946 : The script has been improved!  See this <a href="http://forums.omnigroup.com/showthread.php?t=20397" title="Copy last sent message to Clippings - The Omni Group Forums">thread on the Omni Group forums</a> for the update.  Thanks to <a href="http://forums.omnigroup.com/member.php?u=5000" title="The Omni Group Forums - View Profile: whpalmer4">whpalmer4</a> for the modifications.</p><p style="padding:0;margin:0;font-style:italic;" class="removed_link">The text was modified to remove a link to http://docs.blacktree.com/quicksilver/triggers on January 28th, 2011.</p>]]></content:encoded> <wfw:commentRss>http://dltj.org/article/copy-last-sent-message-as-rtf-link/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> </channel> </rss>
<!-- Served from: dltj.org @ 2012-02-11 12:15:34 by W3 Total Cache -->
