<?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>Red Sweater Blog &#187; AppleScript</title>
	<atom:link href="http://www.red-sweater.com/blog/category/articles/programming/applescript/feed" rel="self" type="application/rss+xml" />
	<link>http://www.red-sweater.com/blog</link>
	<description>Mac &#38; Technology Writings by Daniel Jalkut</description>
	<lastBuildDate>Tue, 17 Jan 2012 22:03:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>Usable Keychain Scripting For Lion</title>
		<link>http://www.red-sweater.com/blog/2035/usable-keychain-scripting-for-lion</link>
		<comments>http://www.red-sweater.com/blog/2035/usable-keychain-scripting-for-lion#comments</comments>
		<pubDate>Fri, 29 Jul 2011 19:15:43 +0000</pubDate>
		<dc:creator>Daniel Jalkut</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Hacking]]></category>

		<guid isPermaLink="false">http://www.red-sweater.com/blog/?p=2035</guid>
		<description><![CDATA[I&#8217;m tracking down a mysterious behavior of Safari in Lion, where it seems to fail to enter my password for logins that I&#8217;ve saved to the keychain. In the process of looking into this, I noticed that &#8220;Keychain Scripting&#8221; has mysteriously disappeared from Lion. As far as I can tell you must copy Apple&#8217;s scripting addition [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m tracking down a mysterious behavior of Safari in Lion, where it seems to fail to enter my password for logins that I&#8217;ve saved to the keychain. In the process of looking into this, I noticed that &#8220;Keychain Scripting&#8221; has mysteriously disappeared from Lion. As far as I can tell you must copy Apple&#8217;s scripting addition from Snow Leopard in order to keep using it.</p>
<p>On the other hand, I wrote an alternative years ago, called <a href="http://www.red-sweater.com/blog/170/usable-keychain-scripting">Usable Keychain Scripting</a>. Its main advantage over Apple&#8217;s implementation is that it is (or at least, was) enormously faster. Today I updated the app to be 64-bit compatible and to fix a pernicious bug in which the password value returned for a keychain item would sometimes have garbage appended to the end of it.</p>
<p><a href="http://red-sweater.com/blog/downloads/UsableKeychainScripting.dmg">Download Usable Keychain Scripting 1.0b4</a></p>
<p>This is not a supported product, and your success with it may vary. But it has been very handy in the past for me, and hopefully it will come in handy for you if you need to script the keychain.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.red-sweater.com/blog/2035/usable-keychain-scripting-for-lion/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Restore Safari&#8217;s Downloads Keyboard Shortcut</title>
		<link>http://www.red-sweater.com/blog/1949/restore-safaris-downloads-keyboard-shortcut</link>
		<comments>http://www.red-sweater.com/blog/1949/restore-safaris-downloads-keyboard-shortcut#comments</comments>
		<pubDate>Fri, 22 Jul 2011 18:51:35 +0000</pubDate>
		<dc:creator>Daniel Jalkut</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Lion]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.red-sweater.com/blog/?p=1949</guid>
		<description><![CDATA[I&#8217;m pretty excited about most of the enhancements in OS X Lion, and in Safari 5.1, which was released along with it. But one of the most annoying changes in the version of Safari that ships with Lion is the removal of any keyboard shortcut for showing and hiding the active downloads list. Downloads used [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m pretty excited about most of the enhancements in OS X Lion, and in Safari 5.1, which was released along with it. But one of the most annoying changes in the version of Safari that ships with Lion is the removal of any keyboard shortcut for showing and hiding the active downloads list.</p>
<p>Downloads used to be shown in a completely separate window, which could be toggled using the keyboard shortcut Cmd-Opt-L. In Lion, they appear in a popover panel attached to the toolbar of whatever browser window you happen to be using. Unfortunately, there is no keyboard shortcut to toggle the appearance of this popover.</p>
<p>Using <a href="http://www.red-sweater.com/fastscripts/">FastScripts</a> and a simple UI Scripting script, I was able to restore this functionality, so that Safari on Lion toggles the panel using the familiar Cmd-Opt-L shortcut.</p>
<p><a href="http://www.red-sweater.com/AppleScript/ToggleDownloadsPopover.zip">Download the &#8220;Toggle Downloads Popover&#8221; script</a></p>
<p>Download the script, and copy it to:</p>
<p>[Home] -&gt; Library -&gt; Scripts -&gt; Applications -&gt; Safari</p>
<p>Here it will show up in FastScripts (or Apple&#8217;s script menu) only when Safari is the front-most app. You can also assign it a keyboard shortcut, like Cmd-Opt-L, that will only be active when Safari is active.</p>
<p><strong>Important: </strong>If your Mac is not configured to run with English as the primary language, the script will not work without a minor adjustment. You will need to open up the script and change the text string &#8220;Downloads&#8221; to the language-specific description for the downloads panel in your language. For example, to make it work with Safari running in Spanish, you would change the string to &#8220;Descargas&#8221;.</p>
<p>I find it very useful to be able to popup the panel when I am checking on the status of a long download, or when I want to check quickly whether I already downloaded something I had intended to. Hope this script works well for you as well!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.red-sweater.com/blog/1949/restore-safaris-downloads-keyboard-shortcut/feed</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Toggle Twitter</title>
		<link>http://www.red-sweater.com/blog/1646/toggle-twitter</link>
		<comments>http://www.red-sweater.com/blog/1646/toggle-twitter#comments</comments>
		<pubDate>Sat, 22 Jan 2011 20:09:53 +0000</pubDate>
		<dc:creator>Daniel Jalkut</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[FastScripts]]></category>
		<category><![CDATA[Usability]]></category>

		<guid isPermaLink="false">http://www.red-sweater.com/blog/?p=1646</guid>
		<description><![CDATA[I use Twitter. A lot, and almost entirely on my Mac desktop. Over the years, I have switched between many popular client applications, often returning to old favorites when the specific advantages of one outweighs the advantages of another for my current priorities. The way I use Twitter is to leave one of these client [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://twitter.com/danielpunkass">I use Twitter</a>. A lot, and almost entirely on my Mac desktop. Over the years, I have switched between many popular client applications, often returning to old favorites when the specific advantages of one outweighs the advantages of another for my current priorities.</p>
<p>The way I use Twitter is to leave one of these client applications running in the background, with all the notification settings set to off. I still check it quite often, but it&#8217;s on my terms. If I get deep into concentration working on some bug, chatting with a friend, or or watching a video, I don&#8217;t want Twitter interrupting me.</p>
<p><a href="http://iconfactory.com/software/twitterrific">Twitterrific</a> was the first desktop client I used, and I can&#8217;t remember whether it was the default choice or if I picked it, but I got in the habit of using the global keyboard shortcut <strong>Cmd-Ctrl-T</strong> to toggle the window&#8217;s visibility. When I tried other Twitter apps, I made a point of setting the preference in that app to match the same shortcut.</p>
<p>Eventually I tried an app that didn&#8217;t support a setting for a global keyboard shortcut, so I had to write a script to do it for me. It occurred to me at some point that I could write a single AppleScript to handle the toggling of visibility regardless of which app I was using.</p>
<p><a href="http://www.red-sweater.com/AppleScript/ToggleTwitter.zip">Download &#8220;Toggle Twitter&#8221;</a></p>
<p>The script logic is pretty simple: given a list of common Twitter app-names, is one of them running? If so, toggle it. If not, launch it. If you&#8217;re using something else, just add it to the list, and it should work perfectly.</p>
<p>I used <a href="http://www.red-sweater.com/fastscripts/">FastScripts</a> to hook this up to the global shortcut <strong>Cmd-Ctrl-T</strong> because it matches my historic muscle memory, and well, T is for Twitter.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.red-sweater.com/blog/1646/toggle-twitter/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Jump To PayPal Transaction</title>
		<link>http://www.red-sweater.com/blog/1174/jump-to-paypal-transaction</link>
		<comments>http://www.red-sweater.com/blog/1174/jump-to-paypal-transaction#comments</comments>
		<pubDate>Fri, 16 Apr 2010 15:40:30 +0000</pubDate>
		<dc:creator>Daniel Jalkut</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Business]]></category>
		<category><![CDATA[FastScripts]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.red-sweater.com/blog/?p=1174</guid>
		<description><![CDATA[I complained on Twitter about PayPal&#8217;s unfortunate transaction search utility, which doesn&#8217;t recognize the transaction ID itself as a search term. Georg C. Brückmann chimed in with a semi-solution, which is a URL template you can use to jump directly to a PayPal transaction by ID. Take the root PayPal URL for your country, and [...]]]></description>
			<content:encoded><![CDATA[<p>I <a href="http://twitter.com/danielpunkass/status/12283008210">complained on Twitter</a> about PayPal&#8217;s unfortunate transaction search utility, which doesn&#8217;t recognize <em>the transaction ID</em> itself as a search term.</p>
<p>Georg C. Brückmann <a href="http://twitter.com/gcbrueckmann/status/12283277096">chimed in</a> with a semi-solution, which is a URL template you can use to jump directly to a PayPal transaction by ID. Take the root PayPal URL for your country, and add &#8220;vst/id=&#8221; followed by the PayPal transaction ID. In the United States, this leads to a URL like: <a href="https://www.paypal.com/vst/id=1234">https://www.paypal.com/vst/id=1234﻿</a>.</p>
<p>It&#8217;s sad to say that remembering a static PayPal URL and pasting in the transaction ID in the magic location is indeed easier than navigating PayPal&#8217;s slow and awkward transaction history UI. But it could be even easier with a little automation.</p>
<p><a href="http://www.red-sweater.com/AppleScript/JumpToPayPalTransactionID.zip">Jump To PayPal Transaction ID</a> is a simple AppleScript that prompts you for a transaction ID, constructs the desired URL, and opens it in your default browser. If you don&#8217;t live in the United States, open the script in AppleScript Editor and alter the template URL contained within it.</p>
<p>I put this in my Safari-specific scripts folder:</p>
<pre>[Home] | Library | Scripts | Applications | Safari</pre>
<p>So it&#8217;s available from <a href="http://www.red-sweater.com/fastscripts/">FastScripts</a> whenever I&#8217;m in Safari. Problem solved.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.red-sweater.com/blog/1174/jump-to-paypal-transaction/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>FastScripts Plugin For Google Quick Search Box</title>
		<link>http://www.red-sweater.com/blog/1144/fastscripts-google-quick-search</link>
		<comments>http://www.red-sweater.com/blog/1144/fastscripts-google-quick-search#comments</comments>
		<pubDate>Wed, 24 Mar 2010 19:43:48 +0000</pubDate>
		<dc:creator>Daniel Jalkut</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[FastScripts]]></category>
		<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://www.red-sweater.com/blog/?p=1144</guid>
		<description><![CDATA[I love to be surprised by what customers manage to do with my products, so I was thrilled when Martin Kühl wrote to tell me about his GitHub project that provides a FastScripts plugin for Google Quick Search Box. If you&#8217;re not familiar with Google Quick Search Box, it&#8217;s basically a Quicksilver-style launcher, which can [...]]]></description>
			<content:encoded><![CDATA[<p>I love to be surprised by what customers manage to do with my products, so I was thrilled when <a href="http://mkhl.github.com/">Martin Kühl</a> wrote to tell me about <a href="http://github.com/mkhl/fastscripts.hgs">his GitHub project</a> that provides a <a href="http://www.red-sweater.com/fastscripts/">FastScripts</a> plugin for <a href="http://code.google.com/p/qsb-mac/">Google Quick Search Box</a>.</p>
<p>If you&#8217;re not familiar with Google Quick Search Box, it&#8217;s basically a Quicksilver-style launcher, which can open all manner of documents and also do Google searches for whatever you&#8217;re typing, all at once. With the addition of Martin&#8217;s FastScripts plugin, it also magically gains the ability to directly run FastScripts scripts.</p>
<p>So if I bring up the quick search box and start typing the name of one of my scripts, it shows up instantly:</p>
<p><img src="http://www.red-sweater.com/blog/images/Search_Bar-20100324-153353.jpg"/></p>
<p>Significantly, this is more meaningful than simply knowing about where the scripts are located, and running them. Martin mentioned to me that he was taking advantage of my &#8220;API&#8221; for accessing and running the scripts. Huh? What? I don&#8217;t have an API, do I? Oh yes, but of course! AppleScript itself!  Martin used the fact that FastScripts exposes AppleScript access to its library of scripts, and for executing those scripts <em>in the context of FastScripts</em>. So when you select and run a script from the GQSB, it runs exactly as it would if you selected it from the FastScripts menu itself.</p>
<p>A clever piece of work by Martin that takes unexpected advantage of these hooks I put into FastScripts. If you use both FastScripts and GQSB, you might want to check his project out!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.red-sweater.com/blog/1144/fastscripts-google-quick-search/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert To MP3</title>
		<link>http://www.red-sweater.com/blog/942/convert-to-mp3</link>
		<comments>http://www.red-sweater.com/blog/942/convert-to-mp3#comments</comments>
		<pubDate>Fri, 11 Sep 2009 13:03:01 +0000</pubDate>
		<dc:creator>Daniel Jalkut</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[FastScripts]]></category>

		<guid isPermaLink="false">http://www.red-sweater.com/blog/?p=942</guid>
		<description><![CDATA[I store most of my iTunes tracks in Apple&#8217;s AAC encoding format, but from time to time I find it useful to convert some tracks in my library to MP3 format. While AAC is convenient and works on my iPod, iPhone, etc., I have to concede that MP3 format is a little more universal. In [...]]]></description>
			<content:encoded><![CDATA[<p></p>
<p>I store most of my iTunes tracks in Apple&#8217;s AAC encoding format, but from time to time I find it useful to convert some tracks in my library to MP3 format. While AAC is convenient and works on my iPod, iPhone, etc., I have to concede that MP3 format is a little more universal.</p>
<p>In the iTunes &#8220;Advanced&#8221; menu you&#8217;ll find a convenient conversion item, which lets you convert the encoding of a selected song file to whatever your default import encoding is.&nbsp;The problem is, since I&#8217;m always importing as AAC, the only option it gives me is to convert to AAC:</p>
<p></p>
<p style="margin-bottom:2em;">
<img src="http://www.red-sweater.com/blog/images/CreateAAC-20090910-130838.jpg"/>
</p>
<p>
To use iTunes to convert a song to MP3 format, I would have to open up Preferences, click the Import Settings button, and change my default encoding choice to the MP3 encoder. Then I would have to close preferences, do the conversion, and then preferences and switch my encoding choice back to AAC.
</p>
<p>
YUCK!
</p>
<p>
AppleScript to the rescue. Because iTunes exposes an attribute &#8220;current encoder&#8221;, and because AppleScript exposes a command &#8220;convert&#8221;, I can do all the mucking about behind the scenes in a quick-running script that performs theses steps:
</p>
<ol>
<li>Save the current encoding setting.</li>
<li>Switch to the MP3 encoder.</li>
<li>Convert the selected songs.</li>
<li>Set the encoder back to whatever it was</li>
</ol>
<p>
Download the <a href="http://www.red-sweater.com/AppleScript/ConvertToMP3.zip">Convert to MP3</a> script. Install it in [Home] -> Library -> Scripts -> Applications -> iTunes. It will show up in <a href="http://www.red-sweater.com/fastscripts/">FastScript&#8217;s</a> iTunes-specific section, where you can assign a keyboard shortcut if you like.
</p>
<p>
Now when I want to convert songs to MP3 format, I just select them in iTunes, and press the keyboard shortcut I assigned to the script in FastScripts:
</p>
<p style="margin-bottom:2em;">
<img src="http://www.red-sweater.com/blog/images/ConvertToMP3-20090910-131558.jpg"/>
</p>
<p>The conversion happens immediately and my encoding preference is not disturbed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.red-sweater.com/blog/942/convert-to-mp3/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Go To My Music</title>
		<link>http://www.red-sweater.com/blog/930/go-to-my-music</link>
		<comments>http://www.red-sweater.com/blog/930/go-to-my-music#comments</comments>
		<pubDate>Thu, 10 Sep 2009 16:57:42 +0000</pubDate>
		<dc:creator>Daniel Jalkut</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[FastScripts]]></category>

		<guid isPermaLink="false">http://www.red-sweater.com/blog/?p=930</guid>
		<description><![CDATA[In response to the updated iTunes 9.0 from Apple, fellow developer Todd Ditchendorf complained on Twitter that the application still lacks a convenient shortcut for &#8220;jumping back to the music.&#8221; I use iTunes all the time, but it hadn&#8217;t occurred to me how annoying this is. You&#8217;ve been fishing around in the iTunes store, or [...]]]></description>
			<content:encoded><![CDATA[<p>In response to the updated iTunes 9.0 from Apple, fellow developer Todd Ditchendorf <a href="http://twitter.com/iTod/status/3882746695">complained on Twitter</a> that the application still lacks a convenient shortcut for &#8220;jumping back to the music.&#8221;</p>
<p>I use iTunes all the time, but it hadn&#8217;t occurred to me how annoying this is. You&#8217;ve been fishing around in the iTunes store, or the Podcasts source, or Audiobooks, or any of the numerous other zones of the application. Then, you get the crazy notion to actually use iTunes to listen to music, so you jump to the search box and start searching. Bah! It&#8217;s not searching my music, it&#8217;s searching the App Store, or whatever. Now you have to go click the &#8220;Music&#8221; icon, and start your search again.</p>
<p>So yes, it would be handy to have a convenient shortcut to switch back to the Music source, and that is where my scripting utility <a href="http://www.red-sweater.com/fastscripts/">FastScripts</a> is particularly potent. It was a little tricky to deduce which magic scripting command would achieve the goal, but I think I figured it out:</p>
<pre>tell application "iTunes"
	set view of (browser window 1) to user playlist 1
end tell
</pre>
<p>
Save this <a href="http://www.red-sweater.com/AppleScript/GoToMusic.zip">as a script file</a> in your home directory:</p>
<pre>[Home] -&gt; Library -&gt; Scripts -&gt; Applications -&gt; iTunes
</pre>
<p>
This is an &#8220;Application-specific&#8221; scripts folder for iTunes, meaning it will only show up when the iTunes application is actually active and frontmost. Now you can open up FastScripts (free for up to 10 shortcuts) and use it to assign a keyboard shortcut:
</p>
<p>
<img src="http://www.red-sweater.com/blog/images/KeyboardShortcut-20090910-123715.jpg"/>
</p>
<p>
Now when I&#8217;m browsing iTunes, I just press cmd-option-M and it jumps instantly to my music!
</p>
<p>I have a bunch of iTunes scripts that I find useful. Over the next few days I&#8217;ll be highlighting other convenient tricks I use to make iTunes a more useful application through its scriptability.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.red-sweater.com/blog/930/go-to-my-music/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>JSTalk &#8211; An Alternative To AppleScript?</title>
		<link>http://www.red-sweater.com/blog/775/jstalk-an-alternative-to-applescript</link>
		<comments>http://www.red-sweater.com/blog/775/jstalk-an-alternative-to-applescript#comments</comments>
		<pubDate>Fri, 27 Mar 2009 03:53:29 +0000</pubDate>
		<dc:creator>Daniel Jalkut</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Business]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://www.red-sweater.com/blog/?p=775</guid>
		<description><![CDATA[My friend Gus Mueller of Flying Meat is having a busy week. On Tuesday it was revealed that his awesome image editing application, Acorn, is part of the MacHeist 3 Bundle. I have been openly critical of these rock-bottom-pricing bundles in the past, and I remain uncertain as to their long-term benefits for the Mac [...]]]></description>
			<content:encoded><![CDATA[<p>My friend Gus Mueller of <a href="http://flyingmeat.com/">Flying Meat</a> is having a busy week. On Tuesday it was revealed that his awesome image editing application, <a href="http://flyingmeat.com/acorn/">Acorn</a>, is part of the <a href="http://www.macheist.com/">MacHeist 3 Bundle</a>. I have been openly critical of these rock-bottom-pricing bundles in the past, and I remain uncertain as to their long-term benefits for the Mac software ecosystem. But in the short-term, consumers obviously have the option of picking up some amazing software for an unbeatable price. And if folks like Gus end up benefiting then I wish them the best.</p>
<p>
In the wake of his high profile MacHeist debut, Gus announced something new today which is decidedly less consumer-oriented (though if it takes off, it could certainly have wide-reaching consequences). <a href="http://gusmueller.com/blog/archives/2009/03/introducing_jstalk__an_alternative_to_applescript.html">JSTalk</a> is Gus&#8217;s JavaScript-based answer to what he sees as outdated and clunky about AppleScript, Apple&#8217;s preferred scripting language on the Mac.
</p>
<p>
For starters, Gus&#8217;s JSTalk provides syntactic sugar on top of standard JavaScript in order to give it some comfortable Objective-C style conveniences. Then, he provides a teeny bit of source code that any application can embed in order to respond to incoming JavaScript commands. This results in a scenario where an Objective-C based application can easily expose its internals to other applications, so that a script written in JSTalk can control it from another application.
</p>
<p>
I&#8217;m excited about the idea of JavaScript taking a more prominent role in the scripting infrastructure of Mac OS X. In fact, about 9 months ago I <a href="http://www.red-sweater.com/blog/502/apples-script">wrote some challenging words</a> about my opinion on the matter. Responding to Apple&#8217;s impressive enhancements to JavaScript in the context of WebKit:
</p>
<blockquote><p>
I hold a soft spot in my heart for AppleScript. But I’m slightly more of a pragmatist than a romantic. If JavaScript is what Apple cares most about, and JavaScript is where massive performance improvements are going to be made, then Apple should leverage those improvements to the benefit of every desktop scripter.
</p></blockquote>
<p>
Since then, Apple has given no indication of pursuing a system-wide infrastructure for JavaScript scripting. So in comes Gus Mueller with JSTalk, and solves the problem. Right? Well, sort of. Gus&#8217;s idea is very cool and clever given the constraints he&#8217;s working with. Namely, he can&#8217;t easily control how every application works, or how it interacts with the system and every other application. His solution is cool, and may even be worth adding support for to your application, but it&#8217;s not as cool as a system-wide, Apple-endorsed solution would be.
</p>
<p>
Michael Tsai makes <a href="http://mjtsai.com/blog/2009/03/26/introducing-jstalk/">some smart observations</a> about JSTalk, also agreeing that it&#8217;s cool, but taking exception to Gus&#8217;s claim that getting away from the rigid structure of AppleScript&#8217;s XML-based scripting dictionaries is a good thing:
</p>
<blockquote><p>
I think defining the object model, e.g. using XML, is a feature. Otherwise there’s no separation between the scripting interface and the application’s unstable internal interfaces.
</p></blockquote>
<p>
Taking a closer look at Michael&#8217;s post, I think I could have avoided this somewhat long-winded post by starting simply with, &#8220;Yeah, what Michael said.&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.red-sweater.com/blog/775/jstalk-an-alternative-to-applescript/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Generating Footnotes With MarsEdit</title>
		<link>http://www.red-sweater.com/blog/517/generating-footnotes-with-marsedit</link>
		<comments>http://www.red-sweater.com/blog/517/generating-footnotes-with-marsedit#comments</comments>
		<pubDate>Tue, 15 Jul 2008 03:01:33 +0000</pubDate>
		<dc:creator>Daniel Jalkut</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[MarsEdit]]></category>

		<guid isPermaLink="false">http://www.red-sweater.com/blog/?p=517</guid>
		<description><![CDATA[One of the aspects of MarsEdit which appeals to me is the way it hides much of its power and versatility beneath a relatively simple interface. Shimone Samuel recognized the power of MarsEdit&#8217;s scriptability and powerful markup macros, and came up with a pretty cool solution for automating footnote generation. Nice work, Shimone! It&#8217;s great [...]]]></description>
			<content:encoded><![CDATA[<p>One of the aspects of MarsEdit which appeals to me is the way it hides much of its power and versatility beneath a relatively simple interface. Shimone Samuel recognized the power of MarsEdit&#8217;s scriptability and powerful markup macros, and came up with a pretty cool <a href="http://www.likewowonline.net/web/dev/footnotes-applescript-marsedit.html">solution for automating footnote generation</a>.</p>
<p>
Nice work, Shimone! It&#8217;s great to see examples like this. As I said, I think it&#8217;s nice the way MarsEdit hides much of its functionality away, but the flip side of that is of course that it can be difficult to realize its full potential. Blog posts such as Shimone&#8217;s do a good job of showing off its hidden strengths.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.red-sweater.com/blog/517/generating-footnotes-with-marsedit/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apple&#8217;s Script</title>
		<link>http://www.red-sweater.com/blog/502/apples-script</link>
		<comments>http://www.red-sweater.com/blog/502/apples-script#comments</comments>
		<pubDate>Tue, 03 Jun 2008 13:11:59 +0000</pubDate>
		<dc:creator>Daniel Jalkut</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Macintosh]]></category>

		<guid isPermaLink="false">http://www.red-sweater.com/blog/?p=502</guid>
		<description><![CDATA[Like the rest of the Mac nerd world, I saw the announcement of SquirrelFish as very promising and inspiring news. The WebKit team has redesigned its JavaScript parser, emphasizing speed performance by switching from a parsed-tree system to a bytecode-interpreted system. The result is a much faster system that apparently offers the promise of even [...]]]></description>
			<content:encoded><![CDATA[<p>Like the rest of the Mac nerd world, I saw the <a href="http://webkit.org/blog/189/announcing-squirrelfish/">announcement of SquirrelFish</a> as very promising and inspiring news. The WebKit team has redesigned its JavaScript parser, emphasizing speed performance by switching from a parsed-tree system to a bytecode-interpreted system. The result is a much faster system that apparently offers the promise of even further optimizations as time goes by.</p>
<p>
KUDOS to the WebKit team! When I last read about JavaScript performance, it was on Jeff Atwood&#8217;s substantial <a href="http://www.codinghorror.com/blog/archives/001023.html">comparison of many browsers</a> and their respective performances.  At that time Safari already stood near the front of the pack, only being narrowly beaten by Opera in terms of overall performance.
</p>
<p>
I expect that unless other browsers have also been dramatically enhancing their JavaScript performance during this time, the SquirrelFish parser will put Apple&#8217;s WebKit far in front of the other major browsers in the market. At a time when JavaScript is being used more and more in web applications, the benefits of this advantage could be magnified into a noticeably superior user experience on many web sites.
</p>
<p><h3>What About AppleScript?</h3>
</p>
<p>
This announcement got me thinking about Apple&#8217;s scripting languages and where the most growth and progress is being seen.  Here we have a dedicated product team, responsible for providing a scripting service more or less only intended for use within the context of a web page. Yet this team seems to have a stronger corporate charter for making progress than the <a href="http://www.apple.com/applescript/">AppleScript</a> team, which is responsible for the language that provides system-wide scripting glue to both users and developers. JavaScript must be the single most prioritized interpreted language being developed within the walls of Apple. Yet AppleScript, an often-maligned proprietary Apple language, is still the system-wide standard.
</p>
<p>
As a variety of web technologies permeate the desktop (and other platforms such as the iPhone), JavaScript is becoming increasingly popular and well-recognized.  While AppleScript is lauded for being accessible to naive users, it&#8217;s <em>factual</em> ease of use is becoming less relevant as JavaScript&#8217;s <em>actual</em> ease of use explodes.  How is JavaScript becoming actually easier for users? By means of simple, forced exposure. Just as an awkward, text-based system such as HTML has become so dominant that many secretaries and construction workers are passably fluent in it, so are the majority of users who are likely to use scripting passably fluent with JavaScript.
</p>
<p>
<strong>Apple should make JavaScript its default scripting language.</strong>
</p>
<p>
There, I said it. It wasn&#8217;t easy, because I hold a soft spot in my heart for AppleScript. But I&#8217;m slightly more of a pragmatist than a romantic. If JavaScript is what Apple cares most about, and JavaScript is where massive performance improvements are going to be made, then Apple should leverage those improvements to the benefit of every desktop scripter.
</p>
<p>
It sounds like I just said &#8220;Apple should kill AppleScript,&#8221; but I didn&#8217;t. You see, the <a href="http://developer.apple.com/documentation/AppleScript/Conceptual/AppleScriptX/Concepts/osa.html">Open Scripting Architecture</a>, on which AppleScript runs, is designed from the start to support multiple languages.  Think of the &#8220;Open Scripting&#8221; part of the system as the part that lets a script tell another application to do something. The specific scripting language you use to accomplish the rest is really of no concern whatsoever. Two languages, such as JavaScript and AppleScript, can easily live side by side.
</p>
<p>
The idea of using JavaScript as a Macintosh scripting language is not new. Mark Aldritt of <a href="http://www.latenightsw.com/">Late Night Software</a> has for years published a plugin called <a href="http://www.latenightsw.com/freeware/JavaScriptOSA/">JavaScript OSA</a> which provides the functionality I&#8217;m talking about. Here&#8217;s a simple script in AppleScript to activate iTunes:
</p>
<p><pre style="padding-left:20px;">
tell application "iTunes"
	activate
end tell
</pre>
<p>And here is the same action written with JavaScript OSA:
</p>
<p><pre style="padding-left:20px;">
with (MacOS.appBySignature('hook'))
{
	activate()
}
</pre>
</p>
<p>
It&#8217;s a little clunky, I&#8217;ll grant you. It&#8217;s a nuisance that in this incarnation, I had to use the old-style application signature code. But these cosmetic problems are easy enough to fix. If Apple provides its own JavaScript language layer for OSA, it could divert the majority of resources it currently spends on AppleScript. Instead of struggling to keep AppleScript &#8220;modern enough,&#8221; these fine engineers could instead devote themselves to  fine-tuning the JavaScript experience for desktop scripting. </p>
<p>
Apple is leading the pack in the development of an interpreted scripting language: JavaScript. It&#8217;s time to move on. Adieu, AppleScript.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.red-sweater.com/blog/502/apples-script/feed</wfw:commentRss>
		<slash:comments>88</slash:comments>
		</item>
	</channel>
</rss>

