<?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/"
	>

<channel>
	<title>Sam&#039;s random musings &#187; AppleScript</title>
	<atom:link href="http://blog.samdevore.com/archives/category/code-development/applescript/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.samdevore.com</link>
	<description>The internet wanderings of a stay at home dad</description>
	<lastBuildDate>Sat, 24 Apr 2010 01:45:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='blog.samdevore.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>How to Shoot Yourself in the Foot in Any Programming Language</title>
		<link>http://blog.samdevore.com/archives/2007/06/27/how-to-shoot-yourself-in-the-foot-in-any-programming-language/</link>
		<comments>http://blog.samdevore.com/archives/2007/06/27/how-to-shoot-yourself-in-the-foot-in-any-programming-language/#comments</comments>
		<pubDate>Wed, 27 Jun 2007 16:11:22 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Code Development]]></category>
		<category><![CDATA[Developer]]></category>
		<category><![CDATA[JAVA]]></category>
		<category><![CDATA[JavaScript/AJAX]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[RealBASIC]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://blog.samdevore.com/archives/2007/06/27/how-to-shoot-yourself-in-the-foot-in-any-programming-language/</guid>
		<description><![CDATA[How to Shoot Yourself in the Foot in Any Programming Language:


fullduplex.org  &#187; How to Shoot Yourself in the Foot in Any Programming Language
The proliferation of modern programming languages (all of which seem to have stolen countless features from one another) sometimes makes it difficult to remember what language you&#8217;re currently using. This guide is [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://face.centosprime.com/wordpress/2007/06/27/how-to-shoot-yourself-in-the-foot-in-any-programming-language/">How to Shoot Yourself in the Foot in Any Programming Language</a>:</p>

<blockquote>
fullduplex.org  &raquo; How to Shoot Yourself in the Foot in Any Programming Language
The proliferation of modern programming languages (all of which seem to have stolen countless features from one another) sometimes makes it difficult to remember what language you&rsquo;re currently using. This guide is offered as a public service to help programmers who [...]
</blockquote>

<p>Oh man so true so true</p>

<p>(Via <a href="http://face.centosprime.com/wordpress">Mind-NOX</a>.)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.samdevore.com/archives/2007/06/27/how-to-shoot-yourself-in-the-foot-in-any-programming-language/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>System-Wide iPhoto Browser</title>
		<link>http://blog.samdevore.com/archives/2006/05/03/system-wide-iphoto-browser/</link>
		<comments>http://blog.samdevore.com/archives/2006/05/03/system-wide-iphoto-browser/#comments</comments>
		<pubDate>Wed, 03 May 2006 19:28:05 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Tools I Use]]></category>

		<guid isPermaLink="false">http://blog.samdevore.com/archives/2006/05/03/system-wide-iphoto-browser/</guid>
		<description><![CDATA[System-Wide iPhoto Browser: 

Great tip from MacOSXHints.com &#8212; a simple Automator action lets you access a browser for your iPhoto photos, without having to launch iPhoto itself. I&#8217;ve added this to my Scripts menu. (Via Michael Tsai.)

#



This is a slick trick and works for iTunes too

(Via Daring Fireball Linked List.)
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.macosxhints.com/article.php?story=20060429075843216">System-Wide iPhoto Browser</a>: 
<blockquote>
<p>Great tip from MacOSXHints.com &#8212; a simple Automator action lets you access a browser for your iPhoto photos, without having to launch iPhoto itself. I&#8217;ve added this to my Scripts menu. (Via <a href="http://mjtsai.com/blog/2006/05/01/ask-for-photos/">Michael Tsai</a>.)</p>

<div><a title="Permanent link to &lsquo;System-Wide iPhoto Browser&rsquo;" href="http://daringfireball.net/linked/2006/may#wed-03-iphoto_browser">#</a></div>
</blockquote>
</p>

<p>This is a slick trick and works for iTunes too</p>

<p>(Via <a href="http://daringfireball.net/linked/">Daring Fireball Linked List</a>.)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.samdevore.com/archives/2006/05/03/system-wide-iphoto-browser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>tow.com Â» blog Â» Aperture Scripting</title>
		<link>http://blog.samdevore.com/archives/2005/12/07/towcom-%c2%bb-blog-%c2%bb-aperture-scripting/</link>
		<comments>http://blog.samdevore.com/archives/2005/12/07/towcom-%c2%bb-blog-%c2%bb-aperture-scripting/#comments</comments>
		<pubDate>Wed, 07 Dec 2005 17:31:00 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Photography]]></category>

		<guid isPermaLink="false">http://blog.samdevore.com/?p=849</guid>
		<description><![CDATA[tow.com Â» blog Â» Aperture Scripting: 

[He] is writing an AppleScript that transfers annotations from my iView catalogs into Aperture image versions. My file structure for my annotated RAW images has been well-documented, and it will make writing this script relatively straightforward â€” if anything in AppleScript can be straightforward! A tricky part was mapping [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.tow.com/2005/11/30/aperture-scripting/">tow.com Â» blog Â» Aperture Scripting</a>: 
<blockquote>
[He] is writing an AppleScript that transfers annotations from my iView catalogs into Aperture image versions. My file structure for my annotated RAW images has been well-documented, and it will make writing this script relatively straightforward â€” if anything in AppleScript can be straightforward! A tricky part was mapping iViewâ€™s annotation field names 
</blockquote>
</p>

<p>Will be interesting to see what dirvers people use with aperture&#8230;</p>

<p>(Via <a href=""></a>.)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.samdevore.com/archives/2005/12/07/towcom-%c2%bb-blog-%c2%bb-aperture-scripting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AppleScript Resources</title>
		<link>http://blog.samdevore.com/archives/2004/10/15/applescript-resources/</link>
		<comments>http://blog.samdevore.com/archives/2004/10/15/applescript-resources/#comments</comments>
		<pubDate>Fri, 15 Oct 2004 14:39:13 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[AppleScript]]></category>

		<guid isPermaLink="false">http://blog.samdevore.com/archives/2004/10/15/applescript-resources/</guid>
		<description><![CDATA[AppleScript Resources: 

Download these AppleScript Reference Guides and sample scripts for Microsoft Office 2004. Check back frequently to access new AppleScript guides and sample scripts.  Microsoft Office 2004 AppleScript Reference guides provide documentation of the AppleScript dictionaries for Office 2004 programs. Learn how to use the classes and commands to create your own scripts.



(Via [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.microsoft.com/mac/resources/resources.aspx?pid=asforoffice">AppleScript Resources</a>: 
<blockquote>
Download these AppleScript Reference Guides and sample scripts for Microsoft Office 2004. Check back frequently to access new AppleScript guides and sample scripts.  Microsoft Office 2004 AppleScript Reference guides provide documentation of the AppleScript dictionaries for Office 2004 programs. Learn how to use the classes and commands to create your own scripts.
</blockquote>
</p>

<p>(Via <a href="http://www.blankreb.com/studiolog.php">Studio Log</a>.)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.samdevore.com/archives/2004/10/15/applescript-resources/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NetNewsWire 2 to Tasks Script</title>
		<link>http://blog.samdevore.com/archives/2004/10/12/netnewswire-2-to-tasks-script/</link>
		<comments>http://blog.samdevore.com/archives/2004/10/12/netnewswire-2-to-tasks-script/#comments</comments>
		<pubDate>Tue, 12 Oct 2004 17:30:21 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[AppleScript]]></category>

		<guid isPermaLink="false">http://blog.samdevore.com/archives/2004/10/12/netnewswire-2-to-tasks-script/</guid>
		<description><![CDATA[NetNewsWire 2 to Tasks Script: 

Iâ€™ve made an updated version of my NetNewsWire to Tasks scripts available. This version works with the new tabbed browsing feature in NetNewsWire 2. If a browser tab is the current tab, it uses that URL and page title, otherwise it uses the selected news item as it did previously.
 [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.alexking.org/blog/2004/10/12/netnewswire-2-to-tasks-script/#comments">NetNewsWire 2 to Tasks Script</a>: 
<blockquote>
<p>Iâ€™ve made an updated version of my <a href="http://www.alexking.org/blog/2004/07/20/tasks-scripts/">NetNewsWire to Tasks scripts</a> available. This version works with the new tabbed browsing feature in NetNewsWire 2. If a browser tab is the current tab, it uses that URL and page title, otherwise it uses the selected news item as it did previously.</p>
    <p><a href="http://www.alexking.org/software/tasks/download/utilities/nnw2_to_tasks.zip">NetNewsWire to Tasks AppleScripts</a> (nnw2_to_tasks.zip 10kB)
</p>
</blockquote>
</p>

<p>Kewl Alex, adding to my menu, I have some ideas to speed these up a little bit</p>

<p>(Via <a href="http://www.alexking.org/blog/index.php">alexking.org: Blog</a>.)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.samdevore.com/archives/2004/10/12/netnewswire-2-to-tasks-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sample AppleScript Test</title>
		<link>http://blog.samdevore.com/archives/2004/06/29/sample-applescript-test/</link>
		<comments>http://blog.samdevore.com/archives/2004/06/29/sample-applescript-test/#comments</comments>
		<pubDate>Wed, 30 Jun 2004 02:05:41 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[AppleScript]]></category>

		<guid isPermaLink="false">http://blog.samdevore.com/archives/2004/06/29/sample-applescript-test/</guid>
		<description><![CDATA[&#60;

div class=&#8217;codeblock&#8217;>

&#8211;Open this script in a new Script Editor window.

&#8211; change this to be the base path of your tasks site

property kUrlToTasks : &#34;http://tasks.samdevore.com/&#34;
property kDefaultTasksID : 27


on encode_text(this_text)
&#160;&#160;&#160;&#160;set the acceptable_characters to &#34;abcdefghijklmnopqrstuvwxyz0123456789_&#34;
&#160;&#160;&#160;&#160;set the encoded_text to &#34;&#34;
&#160;&#160;&#160;&#160;set the character_list to {}
&#160;&#160;&#160;&#160;repeat with this_char in this_text
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;set this_char to the contents of this_char
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if this_char is in the acceptable_characters [...]]]></description>
			<content:encoded><![CDATA[<p>&lt;</p>

<p>div class=&#8217;codeblock&#8217;>
<span class="as_comments">
&#8211;<a href="applescript://com.apple.scripteditor?action=new&#038;script=--%20change%20this%20to%20be%20the%20base%20path%20of%20your%20tasks%20site%0A%0Aproperty%20kUrlToTasks%20%3A%20%22http%3A%2F%2Ftasks.samdevore.com%2F%22%0Aproperty%20kDefaultTasksID%20%3A%2027%0A%0A%0Aon%20encode_text(this_text)%0A%09set%20the%20acceptable_characters%20to%20%22abcdefghijklmnopqrstuvwxyz0123456789_%22%0A%09set%20the%20encoded_text%20to%20%22%22%0A%09set%20the%20character_list%20to%20%7B%7D%0A%09repeat%20with%20this_char%20in%20this_text%0A%09%09set%20this_char%20to%20the%20contents%20of%20this_char%0A%09%09if%20this_char%20is%20in%20the%20acceptable_characters%20then%0A%09%09%09set%20the%20end%20of%20the%20character_list%20to%20this_char%0A%09%09else%0A%09%09%09set%20the%20end%20of%20the%20character_list%20to%20encode_char(this_char)%0A%09%09end%20if%0A%09end%20repeat%0A%09return%20(the%20character_list)%20as%20string%0Aend%20encode_text%0A%0A--%20this%20sub-routine%20is%20used%20to%20encode%20a%20character%20%0Aon%20encode_char(this_char)%0A%09set%20the%20ASCII_num%20to%20(the%20ASCII%20number%20this_char)%0A%09set%20the%20hex_list%20to%20%7B%220%22,%20%221%22,%20%222%22,%20%223%22,%20%224%22,%20%225%22,%20%226%22,%20%227%22,%20%228%22,%20%229%22,%20%22A%22,%20%22B%22,%20%22C%22,%20%22D%22,%20%22E%22,%20%22F%22%7D%0A%09set%20x%20to%20item%20((ASCII_num%20div%2016)%20+%201)%20of%20the%20hex_list%0A%09set%20y%20to%20item%20((ASCII_num%20mod%2016)%20+%201)%20of%20the%20hex_list%0A%09return%20(%22%25%22%20%26%20x%20%26%20y)%20as%20string%0Aend%20encode_char%0A%0Aon%20addToTask(theTitle,%20theUrl,%20theID)%0A%09set%20theLocation%20to%20kUrlToTasks%20%26%20%22index.php%3Fscreen%3Dedit%26id%3D%22%20%26%20theID%20%26%20%22%26task_notes_append%3D%22%0A%09set%20theLocation%20to%20theLocation%20%26%20encode_text(%22%3Cli%3E%3Ca%20href%3D%5C%22%22%20%26%20theUrl%20%26%20%22%5C%22%20rel%3D%5C%22external%5C%22%3E%22%20%26%20theTitle%20%26%20%22%3C%2Fa%3E%3C%2Fli%3E%22)%0A%09tell%20application%20%22System%20Events%22%0A%09%09open%20location%20theLocation%0A%09end%20tell%0Aend%20addToTask%0A%0Atell%20application%20%22NetNewsWire%22%0A%09set%20theTitle%20to%20title%20of%20selectedHeadline%0A%09set%20theUrl%20to%20URL%20of%20selectedHeadline%0A%09tell%20application%20%22Safari%22%0A%09%09set%20this_URL%20to%20the%20URL%20of%20document%201%0A%09end%20tell%0A%09--%20default%20id%20to%20append%20to%0A%09set%20idNumber%20to%20kDefaultTasksID%0A%09set%20AppleScript's%20text%20item%20delimiters%20to%20%22%3F%22%0A%09set%20the%20item_list%20to%20every%20text%20item%20of%20this_URL%0A%09set%20AppleScript's%20text%20item%20delimiters%20to%20%22%22%0A%09if%20item%201%20of%20item_list%20contains%20kUrlToTasks%20then%0A%09%09set%20params%20to%20item%202%20of%20item_list%0A%09%09set%20AppleScript's%20text%20item%20delimiters%20to%20%22%26%22%0A%09%09set%20the%20param_list%20to%20every%20text%20item%20of%20this_URL%0A%09%09set%20AppleScript's%20text%20item%20delimiters%20to%20%22%22%0A%09%09repeat%20with%20param%20in%20param_list%0A%09%09%09if%20param%20contains%20%22id%22%20then%0A%09%09%09%09set%20AppleScript's%20text%20item%20delimiters%20to%20%22%3D%22%0A%09%09%09%09set%20idNumber%20to%20text%20item%202%20of%20param%0A%09%09%09%09set%20AppleScript's%20text%20item%20delimiters%20to%20%22%22%0A%09%09%09end%20if%0A%09%09end%20repeat%0A%09%09--else%0A%09%09--%09display%20dialog%20%22Not%20your%20tasks%20page%20in%20Safari%22%20%26%20item%201%20of%20item_list%0A%09end%20if%0A%09%0A%09my%20addToTask(theTitle,%20theUrl,%20idNumber)%0Aend%20tell%0A">Open this script in a new Script Editor window</a>.<br />
<br /></span>
&#8211;<span class="as_comments"> change this to be the base path of your tasks site</span><br />
<br />
<span class="as_language">property</span> <span class="as_variables">kUrlToTasks</span> : &#34;http://tasks.samdevore.com/&#34;<br />
<span class="as_language">property</span> <span class="as_variables">kDefaultTasksID</span> : 27<br />
<br />
<br />
<span class="as_language">on</span> <span class="as_variables">encode_text</span>(<span class="as_variables">this_text</span>)<br />
&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_language">the</span> <span class="as_variables">acceptable_characters</span> <span class="as_language">to</span> &#34;abcdefghijklmnopqrstuvwxyz0123456789_&#34;<br />
&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_language">the</span> <span class="as_variables">encoded_text</span> <span class="as_language">to</span> &#34;&#34;<br />
&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_language">the</span> <span class="as_variables">character_list</span> <span class="as_language">to</span> {}<br />
&#160;&#160;&#160;&#160;<span class="as_language">repeat</span> <span class="as_language">with</span> <span class="as_variables">this_char</span> <span class="as_language">in</span> <span class="as_variables">this_text</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_variables">this_char</span> <span class="as_language">to</span> <span class="as_language">the</span> <span class="as_language">contents</span> <span class="as_language">of</span> <span class="as_variables">this_char</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">if</span> <span class="as_variables">this_char</span> <span class="as_language">is</span> <span class="as_language">in</span> <span class="as_language">the</span> <span class="as_variables">acceptable_characters</span> <span class="as_language">then</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_language">the</span> <span class="as_language">end</span> <span class="as_language">of</span> <span class="as_language">the</span> <span class="as_variables">character_list</span> <span class="as_language">to</span> <span class="as_variables">this_char</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">else</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_language">the</span> <span class="as_language">end</span> <span class="as_language">of</span> <span class="as_language">the</span> <span class="as_variables">character_list</span> <span class="as_language">to</span> <span class="as_variables">encode_char</span>(<span class="as_variables">this_char</span>)<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">end</span> <span class="as_language">if</span><br />
&#160;&#160;&#160;&#160;<span class="as_language">end</span> <span class="as_language">repeat</span><br />
&#160;&#160;&#160;&#160;<span class="as_language">return</span> (<span class="as_language">the</span> <span class="as_variables">character_list</span>) <span class="as_language">as</span> <span class="as_language">string</span><br />
<span class="as_language">end</span> <span class="as_variables">encode_text</span><br />
<br />
&#8211;<span class="as_comments"> this sub-routine is used to encode a character </span><br />
<span class="as_language">on</span> <span class="as_variables">encode_char</span>(<span class="as_variables">this_char</span>)<br />
&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_language">the</span> <span class="as_variables">ASCII_num</span> <span class="as_language">to</span> (<span class="as_language">the</span> <span class="as_language">ASCII number</span> <span class="as_variables">this_char</span>)<br />
&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_language">the</span> <span class="as_variables">hex_list</span> <span class="as_language">to</span> {&#34;0&#34;, &#34;1&#34;, &#34;2&#34;, &#34;3&#34;, &#34;4&#34;, &#34;5&#34;, &#34;6&#34;, &#34;7&#34;, &#34;8&#34;, &#34;9&#34;, &#34;A&#34;, &#34;B&#34;, &#34;C&#34;, &#34;D&#34;, &#34;E&#34;, &#34;F&#34;}<br />
&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_variables">x</span> <span class="as_language">to</span> <span class="as_language">item</span> ((<span class="as_variables">ASCII_num</span> <span class="as_language">div</span> 16) + 1) <span class="as_language">of</span> <span class="as_language">the</span> <span class="as_variables">hex_list</span><br />
&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_variables">y</span> <span class="as_language">to</span> <span class="as_language">item</span> ((<span class="as_variables">ASCII_num</span> <span class="as_language">mod</span> 16) + 1) <span class="as_language">of</span> <span class="as_language">the</span> <span class="as_variables">hex_list</span><br />
&#160;&#160;&#160;&#160;<span class="as_language">return</span> (&#34;%&#34; &#38; <span class="as_variables">x</span> &#38; <span class="as_variables">y</span>) <span class="as_language">as</span> <span class="as_language">string</span><br />
<span class="as_language">end</span> <span class="as_variables">encode_char</span><br />
<br />
<span class="as_language">on</span> <span class="as_variables">addToTask</span>(<span class="as_variables">theTitle</span>, <span class="as_variables">theUrl</span>, <span class="as_variables">theID</span>)<br />
&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_variables">theLocation</span> <span class="as_language">to</span> <span class="as_variables">kUrlToTasks</span> &#38; &#34;index.php?screen=edit&#38;id=&#34; &#38; <span class="as_variables">theID</span> &#38; &#34;&#38;task_notes_append=&#34;<br />
&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_variables">theLocation</span> <span class="as_language">to</span> <span class="as_variables">theLocation</span> &#38; <span class="as_variables">encode_text</span>(&#34;&#60;li&#62;&#60;a href=\&#34;&#34; &#38; <span class="as_variables">theUrl</span> &#38; &#34;\&#34; rel=\&#34;external\&#34;&#62;&#34; &#38; <span class="as_variables">theTitle</span> &#38; &#34;&#60;/a&#62;&#60;/li&#62;&#34;)<br />
&#160;&#160;&#160;&#160;<span class="as_language">tell</span> <span class="as_language">application</span> &#34;System Events&#34;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">open location</span> <span class="as_variables">theLocation</span><br />
&#160;&#160;&#160;&#160;<span class="as_language">end</span> <span class="as_language">tell</span><br />
<span class="as_language">end</span> <span class="as_variables">addToTask</span><br />
<br />
<span class="as_language">tell</span> <span class="as_language">application</span> &#34;NetNewsWire&#34;<br />
&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_variables">theTitle</span> <span class="as_language">to</span> <span class="as_language">title</span> <span class="as_language">of</span> <span class="as_language">selectedHeadline</span><br />
&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_variables">theUrl</span> <span class="as_language">to</span> <span class="as_language">URL</span> <span class="as_language">of</span> <span class="as_language">selectedHeadline</span><br />
&#160;&#160;&#160;&#160;<span class="as_language">tell</span> <span class="as_language">application</span> &#34;Safari&#34;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_variables">this_URL</span> <span class="as_language">to</span> <span class="as_language">the</span> <span class="as_language">URL</span> <span class="as_language">of</span> <span class="as_language">document</span> 1<br />
&#160;&#160;&#160;&#160;<span class="as_language">end</span> <span class="as_language">tell</span><br />
&#160;&#160;&#160;&#160;&#8211;<span class="as_comments"> default id to append to</span><br />
&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_variables">idNumber</span> <span class="as_language">to</span> <span class="as_variables">kDefaultTasksID</span><br />
&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_language">AppleScript</span>&#8217;s <span class="as_language">text item delimiters</span> <span class="as_language">to</span> &#34;?&#34;<br />
&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_language">the</span> <span class="as_variables">item_list</span> <span class="as_language">to</span> <span class="as_language">every</span> <span class="as_language">text item</span> <span class="as_language">of</span> <span class="as_variables">this_URL</span><br />
&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_language">AppleScript</span>&#8217;s <span class="as_language">text item delimiters</span> <span class="as_language">to</span> &#34;&#34;<br />
&#160;&#160;&#160;&#160;<span class="as_language">if</span> <span class="as_language">item</span> 1 <span class="as_language">of</span> <span class="as_variables">item_list</span> <span class="as_language">contains</span> <span class="as_variables">kUrlToTasks</span> <span class="as_language">then</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_variables">params</span> <span class="as_language">to</span> <span class="as_language">item</span> 2 <span class="as_language">of</span> <span class="as_variables">item_list</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_language">AppleScript</span>&#8217;s <span class="as_language">text item delimiters</span> <span class="as_language">to</span> &#34;&#38;&#34;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_language">the</span> <span class="as_variables">param_list</span> <span class="as_language">to</span> <span class="as_language">every</span> <span class="as_language">text item</span> <span class="as_language">of</span> <span class="as_variables">this_URL</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_language">AppleScript</span>&#8217;s <span class="as_language">text item delimiters</span> <span class="as_language">to</span> &#34;&#34;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">repeat</span> <span class="as_language">with</span> <span class="as_variables">param</span> <span class="as_language">in</span> <span class="as_variables">param_list</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">if</span> <span class="as_variables">param</span> <span class="as_language">contains</span> &#34;id&#34; <span class="as_language">then</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_language">AppleScript</span>&#8217;s <span class="as_language">text item delimiters</span> <span class="as_language">to</span> &#34;=&#34;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_variables">idNumber</span> <span class="as_language">to</span> <span class="as_language">text item</span> 2 <span class="as_language">of</span> <span class="as_variables">param</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_language">AppleScript</span>&#8217;s <span class="as_language">text item delimiters</span> <span class="as_language">to</span> &#34;&#34;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">end</span> <span class="as_language">if</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">end</span> <span class="as_language">repeat</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#8211;<span class="as_comments">else</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#8211;<span class="as_comments">&#160;&#160;&#160;&#160;display dialog &#34;Not your tasks page in Safari&#34; &#38; item 1 of item_list</span><br />
&#160;&#160;&#160;&#160;<span class="as_language">end</span> <span class="as_language">if</span><br />
&#160;&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160;<span class="as_language">my</span> <span class="as_variables">addToTask</span>(<span class="as_variables">theTitle</span>, <span class="as_variables">theUrl</span>, <span class="as_variables">idNumber</span>)<br />
<span class="as_language">end</span> <span class="as_language">tell</span><br /></p>

<!-- AppleScript Formatting End -->
]]></content:encoded>
			<wfw:commentRss>http://blog.samdevore.com/archives/2004/06/29/sample-applescript-test/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A script for Tasks</title>
		<link>http://blog.samdevore.com/archives/2004/06/21/a-script-for-tasks/</link>
		<comments>http://blog.samdevore.com/archives/2004/06/21/a-script-for-tasks/#comments</comments>
		<pubDate>Tue, 22 Jun 2004 01:51:09 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Code Development]]></category>
		<category><![CDATA[Tools I Use]]></category>

		<guid isPermaLink="false">http://blog.samdevore.com/archives/2004/06/21/a-script-for-tasks/</guid>
		<description><![CDATA[This script will take the current message that you are reading in mail.app and open a window in Safari with the tasks new new task screen, the subject of the mail message is the title of the task and the body of the email is the description of the task.]]></description>
			<content:encoded><![CDATA[<p>This is a sample script to create an entry in <a href='http://www.alexking.org/software/tasks'>Tasks</a>.</p>

<p>This script will take the current message that you are reading in mail.app and open a window in Safari with the tasks new new task screen, the subject of the mail message is the title of the task and the body of the email is the description of the task.</p>

<pre><code>&lt;div class="codeblock"&gt;&lt;!-- AppleScript Formatting Start --&gt;
</code></pre>

<p><span class="as_comments">
&#8211;<a href="applescript://com.apple.scripteditor?action=new&#038;script=--%20change%20this%20to%20be%20the%20base%20path%20of%20your%20tasks%20site%0A%0Aproperty%20kUrlToTasks%20%3A%20%22http%3A%2F%2Ftasks.samdevore.com%2F%22%0A%0A%0Aon%20encodeText(thisText)%0A%09set%20the%20acceptableCharacters%20to%20%22abcdefghijklmnopqrstuvwxyz0123456789%22%0A%09set%20the%20encodedText%20to%20%22%22%0A%09set%20the%20characterList%20to%20%7B%7D%0A%09repeat%20with%20thisChar%20in%20thisText%0A%09%09set%20thisChar%20to%20the%20contents%20of%20thisChar%0A%09%09if%20thisChar%20is%20in%20the%20acceptableCharacters%20then%0A%09%09%09set%20the%20end%20of%20the%20characterList%20to%20thisChar%0A%09%09else%0A%09%09%09set%20the%20end%20of%20the%20characterList%20to%20encodeChar(thisChar)%0A%09%09end%20if%0A%09end%20repeat%0A%09return%20(the%20characterList)%20as%20string%0Aend%20encodeText%0A%0A--%20this%20sub-routine%20is%20used%20to%20encode%20a%20character%20%0Aon%20encodeChar(thisChar)%0A%09set%20the%20ASCIINum%20to%20(the%20ASCII%20number%20thisChar)%0A%09set%20the%20hexList%20to%20%7B%220%22,%20%221%22,%20%222%22,%20%223%22,%20%224%22,%20%225%22,%20%226%22,%20%227%22,%20%228%22,%20%229%22,%20%22A%22,%20%22B%22,%20%22C%22,%20%22D%22,%20%22E%22,%20%22F%22%7D%0A%09set%20x%20to%20item%20((ASCIINum%20div%2016)%20+%201)%20of%20the%20hexList%0A%09set%20y%20to%20item%20((ASCIINum%20mod%2016)%20+%201)%20of%20the%20hexList%0A%09return%20(%22%25%22%20%26%20x%20%26%20y)%20as%20string%0Aend%20encodeChar%0Ausing%20terms%20from%20application%20%22Mail%22%0A%09on%20perform%20mail%20action%20with%20messages%20theSelectedMessages%0A%09%09tell%20application%20%22Mail%22%0A%09%09%09if%20(count%20of%20theSelectedMessages)%20is%20equal%20to%200%20then%0A%09%09%09%09display%20dialog%20%22Please%20select%20a%20message%20in%20Mail%20first,%20then%20run%20this%20script%20again.%22%0A%09%09%09else%20if%20(count%20of%20theSelectedMessages)%20is%20equal%20to%201%20then%0A%09%09%09%09set%20eachMessage%20to%20item%201%20of%20theSelectedMessages%0A%09%09%09%09set%20theSource%20to%20content%20of%20eachMessage%0A%09%09%09%09set%20theSubject%20to%20subject%20of%20eachMessage%0A%09%09%09%09my%20createMessageWithSource(theSource,%20theSubject)%0A%09%09%09else%0A%09%09%09%09display%20dialog%20%22Please%20select%20only%20one%20message%20in%20Mail%20first,%20then%20run%20this%20script%20again.%22%0A%09%09%09end%20if%0A%09%09end%20tell%0A%09end%20perform%20mail%20action%20with%20messages%0Aend%20using%20terms%20from%0A%0Aon%20createMessageWithSource(theSource,%20theSubject)%0A%09set%20theUrl%20to%20kUrlToTasks%20%26%20%22index.php%3Fscreen%3Dedit%26taskNotes%3D%22%0A%09%0A%09set%20theUrl%20to%20theUrl%20%26%20encodeText(theSource)%0A%09set%20theUrl%20to%20theUrl%20%26%20%22%26taskTitle%3D%22%20%26%20encodeText(theSubject)%0A%09tell%20application%20%22System%20Events%22%0A%09%09open%20location%20theUrl%0A%09end%20tell%0A%09%0A%09%0Aend%20createMessageWithSource">Open this script in a new Script Editor window</a>.<br />
<br /></span>
&#8211;<span class="as_comments"> change this to be the base path of your tasks site</span><br />
<br />
<span class="as_language">property</span> <span class="as_variables">kUrlToTasks</span> : &#34;http://tasks.samdevore.com/&#34;<br />
<br />
<br />
<span class="as_language">on</span> <span class="as_variables">encodeText</span>(<span class="as_variables">thisText</span>)<br />
&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_language">the</span> <span class="as_variables">acceptableCharacters</span> <span class="as_language">to</span> &#34;abcdefghijklmnopqrstuvwxyz0123456789&#34;<br />
&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_language">the</span> <span class="as_variables">encodedText</span> <span class="as_language">to</span> &#34;&#34;<br />
&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_language">the</span> <span class="as_variables">characterList</span> <span class="as_language">to</span> {}<br />
&#160;&#160;&#160;&#160;<span class="as_language">repeat</span> <span class="as_language">with</span> <span class="as_variables">thisChar</span> <span class="as_language">in</span> <span class="as_variables">thisText</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_variables">thisChar</span> <span class="as_language">to</span> <span class="as_language">the</span> <span class="as_language">contents</span> <span class="as_language">of</span> <span class="as_variables">thisChar</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">if</span> <span class="as_variables">thisChar</span> <span class="as_language">is</span> <span class="as_language">in</span> <span class="as_language">the</span> <span class="as_variables">acceptableCharacters</span> <span class="as_language">then</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_language">the</span> <span class="as_language">end</span> <span class="as_language">of</span> <span class="as_language">the</span> <span class="as_variables">characterList</span> <span class="as_language">to</span> <span class="as_variables">thisChar</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">else</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_language">the</span> <span class="as_language">end</span> <span class="as_language">of</span> <span class="as_language">the</span> <span class="as_variables">characterList</span> <span class="as_language">to</span> <span class="as_variables">encodeChar</span>(<span class="as_variables">thisChar</span>)<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">end</span> <span class="as_language">if</span><br />
&#160;&#160;&#160;&#160;<span class="as_language">end</span> <span class="as_language">repeat</span><br />
&#160;&#160;&#160;&#160;<span class="as_language">return</span> (<span class="as_language">the</span> <span class="as_variables">characterList</span>) <span class="as_language">as</span> <span class="as_language">string</span><br />
<span class="as_language">end</span> <span class="as_variables">encodeText</span><br />
<br />
&#8211;<span class="as_comments"> this sub-routine is used to encode a character </span><br />
<span class="as_language">on</span> <span class="as_variables">encodeChar</span>(<span class="as_variables">thisChar</span>)<br />
&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_language">the</span> <span class="as_variables">ASCIINum</span> <span class="as_language">to</span> (<span class="as_language">the</span> <span class="as_language">ASCII number</span> <span class="as_variables">thisChar</span>)<br />
&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_language">the</span> <span class="as_variables">hexList</span> <span class="as_language">to</span> {&#34;0&#34;, &#34;1&#34;, &#34;2&#34;, &#34;3&#34;, &#34;4&#34;, &#34;5&#34;, &#34;6&#34;, &#34;7&#34;, &#34;8&#34;, &#34;9&#34;, &#34;A&#34;, &#34;B&#34;, &#34;C&#34;, &#34;D&#34;, &#34;E&#34;, &#34;F&#34;}<br />
&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_variables">x</span> <span class="as_language">to</span> <span class="as_language">item</span> ((<span class="as_variables">ASCIINum</span> <span class="as_language">div</span> 16) + 1) <span class="as_language">of</span> <span class="as_language">the</span> <span class="as_variables">hexList</span><br />
&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_variables">y</span> <span class="as_language">to</span> <span class="as_language">item</span> ((<span class="as_variables">ASCIINum</span> <span class="as_language">mod</span> 16) + 1) <span class="as_language">of</span> <span class="as_language">the</span> <span class="as_variables">hexList</span><br />
&#160;&#160;&#160;&#160;<span class="as_language">return</span> (&#34;%&#34; &#38; <span class="as_variables">x</span> &#38; <span class="as_variables">y</span>) <span class="as_language">as</span> <span class="as_language">string</span><br />
<span class="as_language">end</span> <span class="as_variables">encodeChar</span><br />
<span class="as_language">using terms from</span> <span class="as_language">application</span> &#34;Mail&#34;<br />
&#160;&#160;&#160;&#160;<span class="as_language">on</span> <span class="as_language">perform mail action with messages</span> <span class="as_variables">theSelectedMessages</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">tell</span> <span class="as_language">application</span> &#34;Mail&#34;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">if</span> (<span class="as_language">count</span> <span class="as_language">of</span> <span class="as_variables">theSelectedMessages</span>) <span class="as_language">is</span> <span class="as_language">equal to</span> 0 <span class="as_language">then</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">display dialog</span> &#34;Please select a message in Mail first, then run this script again.&#34;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">else</span> <span class="as_language">if</span> (<span class="as_language">count</span> <span class="as_language">of</span> <span class="as_variables">theSelectedMessages</span>) <span class="as_language">is</span> <span class="as_language">equal to</span> 1 <span class="as_language">then</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_variables">eachMessage</span> <span class="as_language">to</span> <span class="as_language">item</span> 1 <span class="as_language">of</span> <span class="as_variables">theSelectedMessages</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_variables">theSource</span> <span class="as_language">to</span> <span class="as_language">content</span> <span class="as_language">of</span> <span class="as_variables">eachMessage</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_variables">theSubject</span> <span class="as_language">to</span> <span class="as_language">subject</span> <span class="as_language">of</span> <span class="as_variables">eachMessage</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">my</span> <span class="as_variables">createMessageWithSource</span>(<span class="as_variables">theSource</span>, <span class="as_variables">theSubject</span>)<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">else</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">display dialog</span> &#34;Please select only one message in Mail first, then run this script again.&#34;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">end</span> <span class="as_language">if</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">end</span> <span class="as_language">tell</span><br />
&#160;&#160;&#160;&#160;<span class="as_language">end</span> <span class="as_language">perform mail action with messages</span><br />
<span class="as_language">end</span> <span class="as_language">using terms from</span><br />
<br />
<span class="as_language">on</span> <span class="as_variables">createMessageWithSource</span>(<span class="as_variables">theSource</span>, <span class="as_variables">theSubject</span>)<br />
&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_variables">theUrl</span> <span class="as_language">to</span> <span class="as_variables">kUrlToTasks</span> &#38; &#34;index.php?screen=edit&#38;taskNotes=&#34;<br />
&#160;&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_variables">theUrl</span> <span class="as_language">to</span> <span class="as_variables">theUrl</span> &#38; <span class="as_variables">encodeText</span>(<span class="as_variables">theSource</span>)<br />
&#160;&#160;&#160;&#160;<span class="as_language">set</span> <span class="as_variables">theUrl</span> <span class="as_language">to</span> <span class="as_variables">theUrl</span> &#38; &#34;&#38;taskTitle=&#34; &#38; <span class="as_variables">encodeText</span>(<span class="as_variables">theSubject</span>)<br />
&#160;&#160;&#160;&#160;<span class="as_language">tell</span> <span class="as_language">application</span> &#34;System Events&#34;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="as_language">open location</span> <span class="as_variables">theUrl</span><br />
&#160;&#160;&#160;&#160;<span class="as_language">end</span> <span class="as_language">tell</span><br />
&#160;&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160;<br />
<span class="as_language">end</span> <span class="as_variables">createMessageWithSource</span>
<!-- AppleScript Formatting End -->
</></></div>
This combines really well with <a href='http://blog.samdevore.com/archives/2004/06/21/macosxhints-add-keyboard-shortcuts-to-applescripts-in-mailapp/'>AppleScript keyboard shortcuts in mail.app</a></p>

<p><a href="http://www.samdevore.com/files/taskMessage.zip">download</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.samdevore.com/archives/2004/06/21/a-script-for-tasks/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
