<?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>James Badger&#039;s Personal Site &#187; AppleScript</title>
	<atom:link href="http://jamesbadger.ca/category/development/applescript/feed/" rel="self" type="application/rss+xml" />
	<link>http://jamesbadger.ca</link>
	<description></description>
	<lastBuildDate>Sat, 14 Jan 2012 21:49:16 +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>Quicksilver + iTunes + Growl</title>
		<link>http://jamesbadger.ca/2008/11/28/quicksilver-itunes-growl/</link>
		<comments>http://jamesbadger.ca/2008/11/28/quicksilver-itunes-growl/#comments</comments>
		<pubDate>Sat, 29 Nov 2008 05:25:23 +0000</pubDate>
		<dc:creator>James Badger</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Local Talk]]></category>

		<guid isPermaLink="false">http://jamesbadger.ca/?p=67</guid>
		<description><![CDATA[One of the most handy tools for Mac has to be Quicksilver. It does 90% of my application launching, and has a plethora of plugins and other features too, like triggers. Triggers work like global hotkeys. For example, I can &#8230; <a href="http://jamesbadger.ca/2008/11/28/quicksilver-itunes-growl/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One of the most handy tools for Mac has to be <a href="http://docs.blacktree.com/quicksilver/what_is_quicksilver">Quicksilver</a>. It does 90% of my application launching, and has a plethora of plugins and other features too, like triggers. Triggers work like global hotkeys. For example, I can press control-F8 in (almost) any application and have iTunes skip to the next song.</p>
<p>What I like to do is be able to rate my iTunes music without having to switch to iTunes or fumble around with the dock contextual menu. With a Quicksilver trigger this is easy, just install the iTunes module and a handful of iTunes-specific triggers are added. However, I prefer to have visual notification that the trigger worked, so I made a few Applescripts to automatically set the rating and tell <a href="http://growl.info/">Growl</a> to display a notification that the change was made.</p>
<p>Script below:</p>
<p><span id="more-67"></span></p>
<pre class="brush: applescript;">
-- check for apps needed
tell application "System Events"
	set iTunesRunning to ¬
		(count of (every process whose name is "iTunes")) > 0
	set growlRunning to ¬
		(count of (every process whose name is "GrowlHelperApp")) > 0
end tell

if iTunesRunning is true and growlRunning is true then
	tell application "iTunes"
		set thistrack to current track
		set therating to 20
		set rating of thistrack to (therating)
		set songdesc to (name of thistrack) &#038; return &#038; (artist of thistrack) &#038; return &#038; (album of thistrack)
		set trackArt to (data of artwork 1 of thistrack)
	end tell
	tell application "GrowlHelperApp"
		set the allNotificationsList to {"Star Rating"}
		set the enabledNotificationsList to {"Star Rating"}
		register as application "Rating Scripts" all notifications allNotificationsList default notifications enabledNotificationsList
		notify with name "Star Rating" title "★☆☆☆☆" description songdesc application name "Rating Scripts" pictImage trackArt
	end tell
end if
</pre>
<p>I saved five version of the script, for ratings 1 to 5, changing the values for each one. &#8220;set therating to 20&#8243; is one star, 40 is two stars, etc. I also changed the ★s for each script. Then in Quicksilver, I added new triggers that activated these scripts, and now control-F1 through F5 rate the current song, and display a Growl notification with track art and information.</p>
]]></content:encoded>
			<wfw:commentRss>http://jamesbadger.ca/2008/11/28/quicksilver-itunes-growl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AppleScript</title>
		<link>http://jamesbadger.ca/2005/09/22/applescript/</link>
		<comments>http://jamesbadger.ca/2005/09/22/applescript/#comments</comments>
		<pubDate>Fri, 23 Sep 2005 03:37:01 +0000</pubDate>
		<dc:creator>James Badger</dc:creator>
				<category><![CDATA[AppleScript]]></category>

		<guid isPermaLink="false">http://www.jamesbadger.ca/?page_id=9</guid>
		<description><![CDATA[Some beginner scripts for use in Apple&#8217;s Script Editor. If you&#8217;re just starting AppleScript, try figuring out what these scripts do and how they do it, then try running them to see if you were correct. TextEdit Word Count tell &#8230; <a href="http://jamesbadger.ca/2005/09/22/applescript/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>
Some beginner scripts for use in Apple&#8217;s Script Editor. If you&#8217;re just starting AppleScript, try figuring out what these scripts do and how they do it, then try running them to see if you were correct.</p>
<h3>TextEdit Word Count</h3>
<pre class="brush: applescript;">
tell application "TextEdit"
	activate
	set _t to text of document 1
	set _num to (number of words of _t) as string
	display dialog (_num &#038; " words found")
end tell
</pre>
<h3>TextEdit Character Count</h3>
<pre class="brush: applescript;">
tell application "TextEdit"
	activate
	set _t to text of document 1
	set _num to (number of characters of _t) as string
	set _list to (words of _t)
	set _num2 to 0
	repeat with i from 1 to (count of _list)
		set _item to item i of _list
		set _num2 to _num2 + (number of characters of _item)
	end repeat
	display dialog (_num &#038; " characters found," &#038; return &#038; _num2 &#038; " visible characters found")
end tell
</pre>
<p>If you have the <a href="http://www.apple.com/applescript/scriptmenu/" title="Apple - Software - AppleScript - Script Menu">Script Menu Extra</a> activated, you can access these scripts directly from TextEdit. Here&#8217;s how.<br />
Open the above scripts in Script Editor, and save them to this folder (Your home folder will be different, of course):<br />
<img src="/wp-downloads/textedit-script.png" title="Save scripts to this folder" style="border: 1px solid #444;" /><br />
If one or more of these folders don&#8217;t already exist, you can create them with the Finder, or from within the Save Dialog Box in Script Editor.
</p>
<h3>Internet Beat Time</h3>
<pre class="brush: applescript;">
set gmt_time to (time to GMT)
if gmt_time is less than 0 then
set gmt_time to -gmt_time
end if
set bmt_dif to gmt_time + 3600
--refresh beat time
set here_time to time of (current date)
set bmt_time to here_time + bmt_dif
if bmt_time is greater than or equal to 86400 then
set bmt_time to bmt_time - 86400
end if
set beat_time to (bmt_time div 86.4)
display dialog "Current Internet Time:" &#038; return &#038; (beat_time) &#038; " Beats"
</pre>
<h3>iTunes Selection Enumerator</h3>
<pre class="brush: applescript;">
-- NOTE: BE VERY CAREFUL WITH THIS SCRIPT.
-- It is very easy to accidently rewrite tag info accidently,
-- and there is no undo. You use it at your own risk. For example,
-- you could accidently delete the track name of every song in
-- your library, or any other field that can be modified
-- through the Info dialog in iTunes.

-- Runs a method of your choice on the selected iTunes songs

on run
	tell application "iTunes"

		set sel_list to selection of window 1

		repeat with i from 1 to (number of items of sel_list)
			set aSong to (item i of sel_list)
			-- aSong is one of the elements of the selection

			-- perform some modifications here, see iTunes AppleScript dictionary,
			-- at iTunes Suite -> track, to see what you could modify.

			-- an option would be to automatically remove ".mp3" from the filenames,
			-- like so:

			set thename to name of aSong

			set toReplace to ".mp3"
			set replaceWith to ""

			if (thename contains toReplace) then
				set OldDelims to AppleScript's text item delimiters
				set AppleScript's text item delimiters to toReplace
				set newText to text items of thename
				set AppleScript's text item delimiters to replaceWith
				set thename to newText as text
				set AppleScript's text item delimiters to OldDelims

				set name of aSong to thename
			end if

			-- other options could include setting 'shuffable', start/finish times,
			-- 'bookmarkable', played date, played count, lyrics, which cannot be
			-- modified by iTunes' Multiple Song Information window.

		end repeat

	end tell

end run
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jamesbadger.ca/2005/09/22/applescript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hacker Translator</title>
		<link>http://jamesbadger.ca/2005/09/11/hacker-translator/</link>
		<comments>http://jamesbadger.ca/2005/09/11/hacker-translator/#comments</comments>
		<pubDate>Mon, 12 Sep 2005 03:27:07 +0000</pubDate>
		<dc:creator>James Badger</dc:creator>
				<category><![CDATA[AppleScript]]></category>

		<guid isPermaLink="false">http://www.jamesbadger.ca/?page_id=6</guid>
		<description><![CDATA[Version 1.15 &#8211; Sept 28/03 Hacker Translator will translate any text you input into &#8216;leet-speak&#8217;. The idea of &#8216;leet-speak&#8217; is to replace as many letters with numbers/symbols as possible. Hacker Translator will also let you customize the translation process, by &#8230; <a href="http://jamesbadger.ca/2005/09/11/hacker-translator/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Version 1.15 &#8211; Sept 28/03</p>
<p>Hacker Translator will translate any text you input into &#8216;leet-speak&#8217;. The idea of &#8216;leet-speak&#8217; is to replace as many letters with numbers/symbols as possible.<br />
Hacker Translator will also let you customize the translation process, by changing options such as enabling/disabling word translation, enabling/disabling character translation, specifying whether characters will translate into numbers or symbols or random. You can also translate &#8216;leet-speak&#8217; back into english, allowing you to decode cryptic H4X0R messages.</p>
<div class="download">
<h4>Download</h4>
<p><a href="wp-downloads/ht115.dmg">Download Disk Image &#8211; 148 KiB</a><br />
<span class="small">MD5 (ht115.dmg) = d81e4b6dedc3280bafbcdb46355eba1d</span><br />
<a href="wp-downloads/ht115.sitx">Download SITX &#8211; 72 KiB</a><br />
<span class="small">MD5 (ht115.sitx) = a865e439b71b99962936dd77e7c53ede</span>
</div>
<h4>What&#8217;s New</h4>
<p>In version 1.15, you can specify which direction of translation you would like, and you can also randomize the character translation process via the preferences window.</p>
<h4>Requirements</h4>
<ul>
<li>A Macintosh</li>
<li>Mac OS X version 10.1.3 or newer</li>
</ul>
<h4>Cost</h4>
<p>Free!</p>
<h4>Known Issues</h4>
<p>None known.</p>
]]></content:encoded>
			<wfw:commentRss>http://jamesbadger.ca/2005/09/11/hacker-translator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

