<?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>Vincent Gable's Blog &#187; Apple Script</title>
	<atom:link href="http://vgable.com/blog/tag/apple-script/feed/" rel="self" type="application/rss+xml" />
	<link>http://vgable.com/blog</link>
	<description>my weblog.</description>
	<lastBuildDate>Tue, 29 Nov 2011 22:20:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How To Check if an Application is Running With AppleScript</title>
		<link>http://vgable.com/blog/2009/04/24/how-to-check-if-an-application-is-running-with-applescript/</link>
		<comments>http://vgable.com/blog/2009/04/24/how-to-check-if-an-application-is-running-with-applescript/#comments</comments>
		<pubDate>Sat, 25 Apr 2009 00:46:39 +0000</pubDate>
		<dc:creator>Vincent Gable</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Sample Code]]></category>
		<category><![CDATA[Apple Script]]></category>
		<category><![CDATA[System Events]]></category>

		<guid isPermaLink="false">http://vgable.com/blog/2009/04/24/how-to-check-if-an-application-is-running-with-applescript/</guid>
		<description><![CDATA[on ApplicationIsRunning(appName) tell application "System Events" to set appNameIsRunning to exists (processes where name is appName) return appNameIsRunning end ApplicationIsRunning Use it like, if ApplicationIsRunning("Mail") then display dialog "Don't forget to write mom!" end if On Mac OS X 10.5, this worked for me even when the application-file&#8217;s name was changed. On 10.4 I do [...]]]></description>
			<content:encoded><![CDATA[<pre>
on ApplicationIsRunning(appName)
	tell application "System Events" to set appNameIsRunning to exists (processes where name is appName)
	return appNameIsRunning
end ApplicationIsRunning
</pre>
<p>Use it like,</p>
<pre>if ApplicationIsRunning("Mail") then
	display dialog "Don't forget to write mom!"
end if</pre>
<p>On Mac OS X 10.5, this worked for me even when the application-file&#8217;s name was changed. On 10.4 I do not expect that it would still work if someone renamed the application, unless you used the <code><strong>creator type</strong></code> to locate the process, not the <code>name</code>.</p>
<p>You might also be interested in how to get the name of the frontmost application, here&#8217;s how:</p>
<pre>tell application "System Events" to set <strong>FrontAppName</strong> to name of first process where frontmost is true
if FrontAppName is "DVD Player" then
	display dialog "Get to work!"
end if
</pre>
]]></content:encoded>
			<wfw:commentRss>http://vgable.com/blog/2009/04/24/how-to-check-if-an-application-is-running-with-applescript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Black on White, White on Black</title>
		<link>http://vgable.com/blog/2009/02/11/black-on-white-white-on-black/</link>
		<comments>http://vgable.com/blog/2009/02/11/black-on-white-white-on-black/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 22:28:35 +0000</pubDate>
		<dc:creator>Vincent Gable</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[MacOSX]]></category>
		<category><![CDATA[Sample Code]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Usability]]></category>
		<category><![CDATA[Apple Script]]></category>
		<category><![CDATA[Color]]></category>
		<category><![CDATA[Ergonomics]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Reading]]></category>

		<guid isPermaLink="false">http://vgable.com/blog/2009/02/11/black-on-white-white-on-black/</guid>
		<description><![CDATA[Command-Option-Control-8 will invert your screen. It&#8217;s a cool looking effect (and quite a prank if you do it to someone else&#8217;s machine), but most importantly it makes tiny-white-text-on-black webpages easier to read. Command Plus/Minus makes text larger/smaller, which helps too. I&#8217;ve known for some time that dark text on a white background is most readable. [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Command-Option-Control-8 will invert your screen</strong>.  It&#8217;s a cool looking effect (and quite a prank if you do it to someone else&#8217;s machine), but most importantly <strong>it makes tiny-white-text-on-black webpages easier to read</strong>.  Command Plus/Minus makes text larger/smaller, which helps too.</p>
<p>I&#8217;ve known for some time that <a href="http://vgable.com/blog/2008/05/27/readable-colors/">dark text on a white background is most readable</a>.  But it until recently it was just &#8220;book learnin&#8221;.  I&#8217;m young, my eyes are healthy, and I can read both color schemes just fine.  I didn&#8217;t have proof I could see.</p>
<p>But I have trouble sleeping sometimes. A few days ago I had an &#8220;accident&#8221; with a 2L bottle of Mountain Dew and a late-night dinner of salty pizza. Look, the details of blame aren&#8217;t important here, the point is I didn&#8217;t get to sleep that night.  Now, when you are very tired, it&#8217;s harder to focus your eyes &#8212; and having to focus them on a computer screen doesn&#8217;t help.  About 3 in the afternoon it got downright <em>painful</em> to read trendy looking webpages with midnight backgrounds and  petite white text.  Remembering the color theory behind contrast, I gave Command-Option-Control-8 a shot, and <strong>holy shit, it worked!</strong>  My screen looked like an adventure in black-lighting gone horribly wrong.  But I could focus on <em>those</em> webpage&#8217;s text more clearly.  Degraded vision from eye-fatigue gave me proof that I could see.</p>
<p>Now please don&#8217;t take this as anything but a <em>biased anecdote</em>.  Trust <a href="http://vgable.com/blog/2008/05/27/readable-colors/">the science</a>, not me!  But it was a neat (and painful) experience.  I can see why Command-Option-Control-8 is there now.  Give it a try sometime, and see if it helps for you.  The most you have to lose is impressing any shoulder surfers with your computer wizardry.  (Honestly though Command-Plus &#8212; make text bigger &#8212; will probably do more to enhance readability.)</p>
<p>Just in case you want to inver the screen programatically, this Apple Script will do the job: <br />
<code>tell application "System Events" to tell application processes to key code 28 using {command down, option down, control down}</code></p>
]]></content:encoded>
			<wfw:commentRss>http://vgable.com/blog/2009/02/11/black-on-white-white-on-black/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>iChat AppleScript / Apple Event Gotcha With &#8220;set status&#8221;</title>
		<link>http://vgable.com/blog/2009/01/18/ichat-applescript-apple-event-bug-with-set-status/</link>
		<comments>http://vgable.com/blog/2009/01/18/ichat-applescript-apple-event-bug-with-set-status/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 03:48:08 +0000</pubDate>
		<dc:creator>Vincent Gable</dc:creator>
				<category><![CDATA[Bug Bite]]></category>
		<category><![CDATA[MacOSX]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Apple Events]]></category>
		<category><![CDATA[Apple Script]]></category>
		<category><![CDATA[iChat]]></category>

		<guid isPermaLink="false">http://vgable.com/blog/2009/01/18/ichat-applescript-apple-event-bug-with-set-status/</guid>
		<description><![CDATA[If you run the AppleScript: tell application "iChat" &#160;&#160;&#160;set status message to "testing" &#160;&#160;&#160;set status to away end tell You might expect to have the away message &#8220;testing&#8221;. But what you get is an empty away message. That&#8217;s because set status destroys your status message. It behaves as if you had selected &#8220;Away&#8221;, &#8220;Available&#8221;, etc. [...]]]></description>
			<content:encoded><![CDATA[<p>If you run the AppleScript:</p>
<p><code><br />
tell application "iChat"<br />
&nbsp;&nbsp;&nbsp;set status message to "testing"<br />
&nbsp;&nbsp;&nbsp;set status to away<br />
end tell<br />
</code></p>
<p>You might expect to have the away message &#8220;testing&#8221;.  But what you get is an empty away message.  That&#8217;s because <strong><code>set status</code> destroys your status message</strong>.  It behaves as if you had selected &#8220;Away&#8221;, &#8220;Available&#8221;, etc. as your status from iChat&#8217;s status menu.</p>
<p>If you want to set a custom away message, <strong>call <code>set status</code> first</strong>, so it won&#8217;t over-write your message.</p>
<p><code><br />
tell application "iChat"<br />
&nbsp;&nbsp;&nbsp;set status to away<br />
&nbsp;&nbsp;&nbsp;set status message to "testing"<br />
end tell<br />
</code></p>
<p>Filled as <a href="http://openradar.appspot.com/radar?id=2633">radar://6505882</a>, but Apple considers it expected behavior.</p>
]]></content:encoded>
			<wfw:commentRss>http://vgable.com/blog/2009/01/18/ichat-applescript-apple-event-bug-with-set-status/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>An AppleScript Quine</title>
		<link>http://vgable.com/blog/2008/10/11/an-applescript-quine/</link>
		<comments>http://vgable.com/blog/2008/10/11/an-applescript-quine/#comments</comments>
		<pubDate>Sat, 11 Oct 2008 19:13:41 +0000</pubDate>
		<dc:creator>Vincent Gable</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[Apple Script]]></category>
		<category><![CDATA[Quine]]></category>

		<guid isPermaLink="false">http://vgable.com/blog/2008/10/11/an-applescript-quine/</guid>
		<description><![CDATA[Here is my first quine. It&#8217;s written in AppleScript, because I wasn&#8217;t able to find, another AppleScript quine. When run quine.applescript will make Script Editor create a new window containing the source code. It&#8217;s particularly meta if you use Script Editor (the default application) to run the quine, because it&#8217;s not just printing itself, it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://vgable.com/code/quine.applescript.zip">Here</a> is my first <a href="http://www.madore.org/~david/computers/quine.html">quine</a>.  It&#8217;s written in AppleScript, because I wasn&#8217;t <a href="http://www.nyx.net/~gthompso/quine.htm">able to find</a>, another AppleScript quine.</p>
<p>When run <a href="http://vgable.com/code/quine.applescript.zip">quine.applescript</a> will make Script Editor create a new window containing the source code.  It&#8217;s particularly meta if you use Script Editor (the default application) to run the quine, because it&#8217;s not just printing itself, it&#8217;s writing itself in the IDE!</p>
<p>Fortunately, <a href="http://imlocation.wordpress.com/2007/11/03/an-applescript-quine/">the problems I&#8217;d originally had with Script Editor and the quine</a> seem to have been fixed.</p>
<p>EDITED TO ADD: Here&#8217;s the quine&#8217;s source, but you really should <a href="http://vgable.com/code/quine.applescript.zip">download it</a> to run it, because wordpress has a habit of subtly mucking with copied code…</p>
<pre>
set d to "on string_from_ASCII_numbers(x)
	set s to ASCII character of item 1 of x
	repeat with i from 2 to number of items in x
		set s to s &#038; (ASCII character of item i of x)
	end repeat
end string_from_ASCII_numbers
set set_d_to to {115, 101, 116, 32, 100, 32, 116, 111, 32}
set scriptEditor to {83, 99, 114, 105, 112, 116, 32, 69, 100, 105, 116, 111, 114}
set quine to string_from_ASCII_numbers(set_d_to) &#038; quote &#038; d &#038; quote &#038; return &#038; d
tell application string_from_ASCII_numbers(scriptEditor) to make new document with properties {contents:quine}"
on string_from_ASCII_numbers(x)
	set s to ASCII character of item 1 of x
	repeat with i from 2 to number of items in x
		set s to s &#038; (ASCII character of item i of x)
	end repeat
end string_from_ASCII_numbers
set set_d_to to {115, 101, 116, 32, 100, 32, 116, 111, 32}
set scriptEditor to {83, 99, 114, 105, 112, 116, 32, 69, 100, 105, 116, 111, 114}
set quine to string_from_ASCII_numbers(set_d_to) &#038; quote &#038; d &#038; quote &#038; return &#038; d
tell application string_from_ASCII_numbers(scriptEditor) to make new document with properties {contents:quine}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://vgable.com/blog/2008/10/11/an-applescript-quine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AppleScript is the Uncanny Valley</title>
		<link>http://vgable.com/blog/2008/06/03/applescript-is-the-uncanny-valley/</link>
		<comments>http://vgable.com/blog/2008/06/03/applescript-is-the-uncanny-valley/#comments</comments>
		<pubDate>Wed, 04 Jun 2008 04:39:40 +0000</pubDate>
		<dc:creator>Vincent Gable</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[MacOSX]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Quotes]]></category>
		<category><![CDATA[Usability]]></category>
		<category><![CDATA[Apple Script]]></category>
		<category><![CDATA[Psychology]]></category>
		<category><![CDATA[Revulsion]]></category>
		<category><![CDATA[Theory]]></category>

		<guid isPermaLink="false">http://vgable.com/blog/2008/06/03/applescript-is-the-uncanny-valley/</guid>
		<description><![CDATA[A interesting theory: I think this “like English but not quite” aspect of AppleScript is the Uncanny Valley of programming languages. Because AppleScript looks like English it is easy to fall into the trap of believing it has the flexibility of English. When that mental model fails its more unsettling than when you screw up [...]]]></description>
			<content:encoded><![CDATA[<p>A interesting theory:</p>
<blockquote><p>I think this “like English but not quite” aspect of AppleScript is the <a href="http://en.wikipedia.org/wiki/Uncanny_valley">Uncanny Valley</a> of programming languages. Because AppleScript looks like English it is easy to fall into the trap of believing it has the flexibility of English. When that mental model fails its more unsettling than when you screw up the syntax in a regular programming language because your mental model isn’t making unwarranted assumptions.</p></blockquote>
<p>&#8211; <a href="http://www.red-sweater.com/blog/502/apples-script#comment-136769">Mark Reid</a></p>
]]></content:encoded>
			<wfw:commentRss>http://vgable.com/blog/2008/06/03/applescript-is-the-uncanny-valley/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

