<?xml version='1.0' encoding='utf-8' ?>
<!--  If you are running a bot please visit this policy page outlining rules you must respect. http://www.livejournal.com/bots/  -->
<rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/' xmlns:media='http://search.yahoo.com/mrss/' xmlns:atom10='http://www.w3.org/2005/Atom'>
<channel>
  <title>Mike&apos;s AutoMagical AppleScript Solutions</title>
  <link>http://automagical.livejournal.com/</link>
  <description>Mike&apos;s AutoMagical AppleScript Solutions - LiveJournal.com</description>
  <lastBuildDate>Fri, 30 Dec 2005 03:24:15 GMT</lastBuildDate>
  <generator>LiveJournal / LiveJournal.com</generator>
  <lj:journal>automagical</lj:journal>
  <lj:journalid>7608264</lj:journalid>
  <lj:journaltype>personal</lj:journaltype>
  <atom10:link rel='hub' href='http://pubsubhubbub.appspot.com/' />
  <image>
    <url>http://l-userpic.livejournal.com/31818731/7608264</url>
    <title>Mike&apos;s AutoMagical AppleScript Solutions</title>
    <link>http://automagical.livejournal.com/</link>
    <width>55</width>
    <height>55</height>
  </image>

<item>
  <guid isPermaLink='true'>http://automagical.livejournal.com/4117.html</guid>
  <pubDate>Fri, 30 Dec 2005 03:24:15 GMT</pubDate>
  <title>10.4 Menu Extras scripting</title>
  <link>http://automagical.livejournal.com/4117.html</link>
  <description>In 10.4 we can land clicks on Menu Extras using System Events. It&apos;s a bit complicated by the fact that most menu extras don&apos;t have titles, and they can be placed in any order the user wishes.&lt;br /&gt;&lt;br /&gt;The first time you run this script, it will start looking in your menu bar for the Bluetooth menu, and then use it to toggle Bluetooth on or off. On subsequent runs the script will have remembered where the Bluetooth menu is, and will just click it immediately. If the menu is later moved or removed, the script will go looking for it again. &lt;a name=&quot;cutid1&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;click here to &lt;a href=&quot;applescript://com.apple.scripteditor?action=new&amp;amp;script=tell%20application%20%22System%20Events%22%20to%20tell%20the%20front%20menu%20bar%20of%20process%20%22SystemUIServer%22%0D%09try%0D%09%09click%20bt_menu%0D%09%09tell%20the%20second%20menu%20item%20of%20the%20front%20menu%20of%20bt_menu%20to%20if%20title%20contains%20%22Bluetooth%22%20then%0D%09%09%09click%0D%09%09else%0D%09%09%09error%0D%09%09end%20if%0D%09on%20error%0D%09%09repeat%20with%20x%20in%20menu%20bar%20items%0D%09%09%09click%20x%0D%09%09%09try%0D%09%09%09%09if%20the%20title%20of%20the%20first%20menu%20item%20of%20the%20front%20menu%20of%20x%20starts%20with%20%22Bluetooth%22%20then%20exit%20repeat%0D%09%09%09end%20try%0D%09%09end%20repeat%0D%09%09set%20bt_menu%20to%20x%0D%09%09try%0D%09%09%09tell%20the%20second%20menu%20item%20of%20the%20front%20menu%20of%20bt_menu%20to%20if%20title%20contains%20%22Bluetooth%22%20then%0D%09%09%09%09click%0D%09%09%09else%0D%09%09%09%09error%0D%09%09%09end%20if%0D%09%09on%20error%0D%09%09%09click%20bt_menu%0D%09%09%09display%20alert%20%22Bluetooth%20Menu%20Extra%20not%20found.%22%0D%09%09end%20try%0D%09end%20try%0Dend%20tell&quot;&gt;open this script in your editor&lt;/a&gt;&lt;pre style=&quot;font-family: &amp;#39;Monaco&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px&quot;&gt;tell application &quot;System Events&quot; to tell the front menu bar of process &quot;SystemUIServer&quot;&lt;br /&gt;	try&lt;br /&gt;		click bt_menu&lt;br /&gt;		tell the second menu item of the front menu of bt_menu to if title contains &quot;Bluetooth&quot; then&lt;br /&gt;			click&lt;br /&gt;		else&lt;br /&gt;			error&lt;br /&gt;		end if&lt;br /&gt;	on error&lt;br /&gt;		repeat with x in menu bar items&lt;br /&gt;			click x&lt;br /&gt;			try&lt;br /&gt;				if the title of the first menu item of the front menu of x starts with &quot;Bluetooth&quot; then exit repeat&lt;br /&gt;			end try&lt;br /&gt;		end repeat&lt;br /&gt;		set bt_menu to x&lt;br /&gt;		try&lt;br /&gt;			tell the second menu item of the front menu of bt_menu to if title contains &quot;Bluetooth&quot; then&lt;br /&gt;				click&lt;br /&gt;			else&lt;br /&gt;				error&lt;br /&gt;			end if&lt;br /&gt;		on error&lt;br /&gt;			click bt_menu&lt;br /&gt;			display alert &quot;Bluetooth Menu Extra not found.&quot;&lt;br /&gt;		end try&lt;br /&gt;	end try&lt;br /&gt;end tell&lt;/pre&gt;</description>
  <comments>http://automagical.livejournal.com/4117.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>2</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://automagical.livejournal.com/4092.html</guid>
  <pubDate>Wed, 28 Dec 2005 17:03:13 GMT</pubDate>
  <title>Browse CoreTypes Icons</title>
  <link>http://automagical.livejournal.com/4092.html</link>
  <description>This is a script I wrote and posted to Apple Lists. It lets you see how various built-in system icons look when used in AppleScript dialog boxes. You can copy out the titles of your favorites, view them as a timed slideshow, pick one from a list, etc. When you quit the script it generates generic dialog code with the appropriate resource reference. &lt;a name=&quot;cutid1&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;click here to &lt;a href=&quot;applescript://com.apple.scripteditor?action=new&amp;amp;script=--%20contact_mike%28%22Compose_Dialog_Icon_0.1.2%22%29%20--%20composes%20mail%20to%20the%20author%20and%20cancels%20script%0Dset%20icon_delay%20to%201%0Dset%20x%20to%200%0Dset%20an_icon%20to%20%22%22%0Dset%20icon_size%20to%20button%20returned%20of%20%28display%20dialog%20%22Which%20icon%20sizes%20would%20you%20like%20to%20view%3F%22%20%26%20return%20%26%20%22%2810k%20and%20up%20is%20considered%20%27Large%27%29%22%20with%20title%20%22Compose%20Dialog%20Icon%200.1.2%22%20buttons%20%7B%22Small%22%2C%20%22Small%20%2B%20Large%22%2C%20%22Large%22%7D%20default%20button%202%29%0Dif%20icon_size%20is%20%22Small%22%20then%0D%09tell%20application%20%22Finder%22%20to%20set%20core_icons%20to%20the%20name%20of%20every%20item%20of%20%28%28%28path%20to%20library%20folder%20from%20system%20domain%20as%20string%29%20%26%20%22CoreServices%3ACoreTypes.bundle%3AContents%3AResources%3A%22%29%20as%20alias%29%20whose%20name%20extension%20is%20%22icns%22%20and%20size%20is%20less%20than%2010000%0Delse%20if%20icon_size%20is%20%22Small%20%2B%20Large%22%20then%0D%09tell%20application%20%22Finder%22%20to%20set%20core_icons%20to%20the%20name%20of%20every%20item%20of%20%28%28%28path%20to%20library%20folder%20from%20system%20domain%20as%20string%29%20%26%20%22CoreServices%3ACoreTypes.bundle%3AContents%3AResources%3A%22%29%20as%20alias%29%20whose%20name%20extension%20is%20%22icns%22%0Delse%20if%20icon_size%20is%20%22Large%22%20then%0D%09tell%20application%20%22Finder%22%20to%20set%20core_icons%20to%20the%20name%20of%20every%20item%20of%20%28%28%28path%20to%20library%20folder%20from%20system%20domain%20as%20string%29%20%26%20%22CoreServices%3ACoreTypes.bundle%3AContents%3AResources%3A%22%29%20as%20alias%29%20whose%20name%20extension%20is%20%22icns%22%20and%20size%20is%20greater%20than%2010000%0Dend%20if%0Dset%20delay_msg%20to%20%22Enter%20a%20number%20of%20seconds%20to%20pause%20between%20icons%3A%22%0Drepeat%0D%09display%20dialog%20delay_msg%20default%20answer%20icon_delay%20with%20title%20%22Compose%20Dialog%20Icon%200.1.2%22%20buttons%20%7B%22Quit%22%2C%20%22Choose%20Icon%22%2C%20%22Start%22%7D%20cancel%20button%201%20default%20button%203%0D%09tell%20result%20to%20set%20%7Bicon_delay%2C%20nav_button%7D%20to%20%7Btext%20returned%2C%20button%20returned%7D%0D%09try%0D%09%09set%20icon_delay%20to%20icon_delay%20as%20integer%0D%09%09exit%20repeat%0D%09on%20error%0D%09%09set%20delay_msg%20to%20%22Error%3A%20Number%20of%20seconds%20must%20be%20a%20positive%20integer.%22%0D%09end%20try%0Dend%20repeat%0Dif%20nav_button%20is%20%22Choose%20Icon%22%20then%0D%09repeat%0D%09%09set%20an_icon%20to%20%28choose%20from%20list%20core_icons%20default%20items%20an_icon%29%20as%20string%0D%09%09if%20an_icon%20is%20%22false%22%20then%20error%20number%20-128%0D%09%09repeat%20with%20z%20from%201%20to%20the%20length%20of%20core_icons%0D%09%09%09if%20item%20z%20of%20core_icons%20is%20an_icon%20then%20exit%20repeat%0D%09%09end%20repeat%0D%09%09set%20x%20to%20z%0D%09%09set%20an_icon%20to%20item%20x%20of%20core_icons%0D%09%09set%20nav_button%20to%20button%20returned%20of%20%28display%20dialog%20%22Icon%20Title%3A%22%20with%20title%20%22Display%20Dialog%22%20default%20answer%20an_icon%20with%20icon%20%28path%20to%20resource%20an_icon%20in%20bundle%20%28%28path%20to%20library%20folder%20from%20system%20domain%20as%20string%29%20%26%20%22CoreServices%3ACoreTypes.bundle%22%29%20as%20alias%29%20buttons%20%7B%22Quit%22%2C%20%22Choose%20Icon%22%2C%20%22Start%22%7D%29%0D%09%09if%20nav_button%20is%20%22Start%22%20then%0D%09%09%09set%20x%20to%20x%20-%201%0D%09%09%09exit%20repeat%0D%09%09else%20if%20nav_button%20is%20%22Quit%22%20then%0D%09%09%09exit%20repeat%0D%09%09end%20if%0D%09end%20repeat%0Dend%20if%0Dif%20nav_button%20is%20%22Start%22%20then%20repeat%0D%09set%20x%20to%20x%20%2B%201%0D%09if%20x%20is%20greater%20than%20the%20length%20of%20core_icons%20then%20set%20x%20to%201%0D%09set%20an_icon%20to%20item%20x%20of%20core_icons%0D%09set%20nav_button%20to%20button%20returned%20of%20%28display%20dialog%20%22Icon%20Title%3A%22%20with%20title%20%22Display%20Dialog%22%20default%20answer%20an_icon%20with%20icon%20%28path%20to%20resource%20an_icon%20in%20bundle%20%28%28path%20to%20library%20folder%20from%20system%20domain%20as%20string%29%20%26%20%22CoreServices%3ACoreTypes.bundle%22%29%20as%20alias%29%20giving%20up%20after%20icon_delay%20buttons%20%7B%22Quit%22%2C%20%22Previous%22%2C%20%22Pause%22%7D%20default%20button%203%29%0D%09if%20nav_button%20is%20not%20%22%22%20then%20repeat%0D%09%09if%20nav_button%20is%20%22Previous%22%20then%0D%09%09%09set%20x%20to%20x%20-%201%0D%09%09%09if%20x%20is%200%20then%20set%20x%20to%20the%20length%20of%20core_icons%0D%09%09%09set%20nav_button%20to%20pause_view%28item%20x%20of%20core_icons%29%0D%09%09else%20if%20nav_button%20is%20%22Next%22%20then%0D%09%09%09set%20x%20to%20x%20%2B%201%0D%09%09%09if%20x%20is%20greater%20than%20the%20length%20of%20core_icons%20then%20set%20x%20to%201%0D%09%09%09set%20nav_button%20to%20pause_view%28item%20x%20of%20core_icons%29%0D%09%09else%20if%20nav_button%20is%20%22Pause%22%20then%0D%09%09%09set%20nav_button%20to%20pause_view%28item%20x%20of%20core_icons%29%0D%09%09else%20if%20nav_button%20is%20%22Resume%22%20then%0D%09%09%09set%20x%20to%20x%20-%201%0D%09%09%09exit%20repeat%0D%09%09else%20if%20nav_button%20is%20%22Quit%22%20then%0D%09%09%09exit%20repeat%0D%09%09end%20if%0D%09%09%0D%09end%20repeat%0D%09if%20nav_button%20is%20%22Quit%22%20then%20exit%20repeat%0Dend%20repeat%0Dif%20nav_button%20is%20%22Quit%22%20then%20handle_quit%28item%20x%20of%20core_icons%29%0Don%20pause_view%28an_icon%29%0D%09button%20returned%20of%20%28display%20dialog%20%22Icon%20Title%3A%22%20with%20title%20%22Display%20Dialog%22%20default%20answer%20an_icon%20with%20icon%20%28path%20to%20resource%20an_icon%20in%20bundle%20%28%28path%20to%20library%20folder%20from%20system%20domain%20as%20string%29%20%26%20%22CoreServices%3ACoreTypes.bundle%22%29%20as%20alias%29%20buttons%20%7B%22Resume%22%2C%20%22Previous%22%2C%20%22Next%22%7D%20default%20button%201%29%0Dend%20pause_view%0Don%20handle_quit%28an_icon%29%0D%09set%20icon_code%20to%20%22display%20dialog%20%5C%22%5C%22%20with%20title%20%5C%22%5C%22%20default%20answer%20%5C%22%5C%22%20with%20icon%20%28path%20to%20resource%20%5C%22%22%20%26%20an_icon%20%26%20%22%5C%22%20in%20bundle%20%28%28path%20to%20library%20folder%20from%20system%20domain%20as%20string%29%20%26%20%5C%22CoreServices%3ACoreTypes.bundle%5C%22%29%20as%20alias%29%22%0D%09display%20dialog%20%22Sample%20code%20for%20%22%20%26%20quoted%20form%20of%20an_icon%20with%20title%20%22Quit%22%20default%20answer%20icon_code%20buttons%20%7B%22Quit%22%2C%20%22Reveal%20Icon%20in%20Finder%22%2C%20%22Copy%20Code%20to%20Clipboard%22%7D%20cancel%20button%201%20default%20button%203%0D%09tell%20result%20to%20set%20%7Bicon_code%2C%20copy_option%7D%20to%20%7Btext%20returned%2C%20button%20returned%7D%0D%09if%20copy_option%20is%20%22Reveal%20Icon%20in%20Finder%22%20then%0D%09%09set%20icon_path%20to%20%28%28path%20to%20library%20folder%20from%20system%20domain%20as%20string%29%20%26%20%22CoreServices%3ACoreTypes.bundle%3AContents%3AResources%3A%22%20%26%20an_icon%29%20as%20alias%0D%09%09tell%20application%20%22Finder%22%0D%09%09%09activate%0D%09%09%09set%20icon_window%20to%20make%20new%20Finder%20window%0D%09%09%09tell%20icon_window%0D%09%09%09%09set%20target%20to%20icon_path%0D%09%09%09%09set%20current%20view%20to%20icon%20view%0D%09%09%09%09set%20toolbar%20visible%20to%20false%0D%09%09%09end%20tell%0D%09%09%09tell%20icon%20view%20options%20of%20icon_window%0D%09%09%09%09set%20arrangement%20to%20arranged%20by%20name%0D%09%09%09%09set%20shows%20icon%20preview%20to%20true%0D%09%09%09%09set%20icon%20size%20to%20128%0D%09%09%09end%20tell%0D%09%09%09reveal%20icon_path%0D%09%09end%20tell%0D%09else%20if%20copy_option%20is%20%22Copy%20Code%20to%20Clipboard%22%20then%0D%09%09set%20the%20clipboard%20to%20icon_code%0D%09end%20if%0Dend%20handle_quit%0Dto%20contact_mike%28script_revision%29%0D%09open%20location%20%22mailto%3Amike.com%40mac.com%3Fsubject%3D%22%20%26%20script_revision%0D%09error%20number%20-128%0Dend%20contact_mike&quot;&gt;open this script in your editor&lt;/a&gt;&lt;pre style=&quot;font-family: &amp;#39;Monaco&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px&quot;&gt;-- contact_mike(&quot;Compose_Dialog_Icon_0.1.2&quot;) -- composes mail to the author and cancels script&lt;br /&gt;set icon_delay to 1&lt;br /&gt;set x to 0&lt;br /&gt;set an_icon to &quot;&quot;&lt;br /&gt;set icon_size to button returned of (display dialog &quot;Which icon sizes would you like to view?&quot; &amp;amp; return &amp;amp; &quot;(10k and up is considered &apos;Large&apos;)&quot; with title &quot;Compose Dialog Icon 0.1.2&quot; buttons {&quot;Small&quot;, &quot;Small + Large&quot;, &quot;Large&quot;} default button 2)&lt;br /&gt;if icon_size is &quot;Small&quot; then&lt;br /&gt;	tell application &quot;Finder&quot; to set core_icons to the name of every item of (((path to library folder from system domain as string) &amp;amp; &quot;CoreServices:CoreTypes.bundle:Contents:Resources:&quot;) as alias) whose name extension is &quot;icns&quot; and size is less than 10000&lt;br /&gt;else if icon_size is &quot;Small + Large&quot; then&lt;br /&gt;	tell application &quot;Finder&quot; to set core_icons to the name of every item of (((path to library folder from system domain as string) &amp;amp; &quot;CoreServices:CoreTypes.bundle:Contents:Resources:&quot;) as alias) whose name extension is &quot;icns&quot;&lt;br /&gt;else if icon_size is &quot;Large&quot; then&lt;br /&gt;	tell application &quot;Finder&quot; to set core_icons to the name of every item of (((path to library folder from system domain as string) &amp;amp; &quot;CoreServices:CoreTypes.bundle:Contents:Resources:&quot;) as alias) whose name extension is &quot;icns&quot; and size is greater than 10000&lt;br /&gt;end if&lt;br /&gt;set delay_msg to &quot;Enter a number of seconds to pause between icons:&quot;&lt;br /&gt;repeat&lt;br /&gt;	display dialog delay_msg default answer icon_delay with title &quot;Compose Dialog Icon 0.1.2&quot; buttons {&quot;Quit&quot;, &quot;Choose Icon&quot;, &quot;Start&quot;} cancel button 1 default button 3&lt;br /&gt;	tell result to set {icon_delay, nav_button} to {text returned, button returned}&lt;br /&gt;	try&lt;br /&gt;		set icon_delay to icon_delay as integer&lt;br /&gt;		exit repeat&lt;br /&gt;	on error&lt;br /&gt;		set delay_msg to &quot;Error: Number of seconds must be a positive integer.&quot;&lt;br /&gt;	end try&lt;br /&gt;end repeat&lt;br /&gt;if nav_button is &quot;Choose Icon&quot; then&lt;br /&gt;	repeat&lt;br /&gt;		set an_icon to (choose from list core_icons default items an_icon) as string&lt;br /&gt;		if an_icon is &quot;false&quot; then error number -128&lt;br /&gt;		repeat with z from 1 to the length of core_icons&lt;br /&gt;			if item z of core_icons is an_icon then exit repeat&lt;br /&gt;		end repeat&lt;br /&gt;		set x to z&lt;br /&gt;		set an_icon to item x of core_icons&lt;br /&gt;		set nav_button to button returned of (display dialog &quot;Icon Title:&quot; with title &quot;Display Dialog&quot; default answer an_icon with icon (path to resource an_icon in bundle ((path to library folder from system domain as string) &amp;amp; &quot;CoreServices:CoreTypes.bundle&quot;) as alias) buttons {&quot;Quit&quot;, &quot;Choose Icon&quot;, &quot;Start&quot;})&lt;br /&gt;		if nav_button is &quot;Start&quot; then&lt;br /&gt;			set x to x - 1&lt;br /&gt;			exit repeat&lt;br /&gt;		else if nav_button is &quot;Quit&quot; then&lt;br /&gt;			exit repeat&lt;br /&gt;		end if&lt;br /&gt;	end repeat&lt;br /&gt;end if&lt;br /&gt;if nav_button is &quot;Start&quot; then repeat&lt;br /&gt;	set x to x + 1&lt;br /&gt;	if x is greater than the length of core_icons then set x to 1&lt;br /&gt;	set an_icon to item x of core_icons&lt;br /&gt;	set nav_button to button returned of (display dialog &quot;Icon Title:&quot; with title &quot;Display Dialog&quot; default answer an_icon with icon (path to resource an_icon in bundle ((path to library folder from system domain as string) &amp;amp; &quot;CoreServices:CoreTypes.bundle&quot;) as alias) giving up after icon_delay buttons {&quot;Quit&quot;, &quot;Previous&quot;, &quot;Pause&quot;} default button 3)&lt;br /&gt;	if nav_button is not &quot;&quot; then repeat&lt;br /&gt;		if nav_button is &quot;Previous&quot; then&lt;br /&gt;			set x to x - 1&lt;br /&gt;			if x is 0 then set x to the length of core_icons&lt;br /&gt;			set nav_button to pause_view(item x of core_icons)&lt;br /&gt;		else if nav_button is &quot;Next&quot; then&lt;br /&gt;			set x to x + 1&lt;br /&gt;			if x is greater than the length of core_icons then set x to 1&lt;br /&gt;			set nav_button to pause_view(item x of core_icons)&lt;br /&gt;		else if nav_button is &quot;Pause&quot; then&lt;br /&gt;			set nav_button to pause_view(item x of core_icons)&lt;br /&gt;		else if nav_button is &quot;Resume&quot; then&lt;br /&gt;			set x to x - 1&lt;br /&gt;			exit repeat&lt;br /&gt;		else if nav_button is &quot;Quit&quot; then&lt;br /&gt;			exit repeat&lt;br /&gt;		end if&lt;br /&gt;		&lt;br /&gt;	end repeat&lt;br /&gt;	if nav_button is &quot;Quit&quot; then exit repeat&lt;br /&gt;end repeat&lt;br /&gt;if nav_button is &quot;Quit&quot; then handle_quit(item x of core_icons)&lt;br /&gt;on pause_view(an_icon)&lt;br /&gt;	button returned of (display dialog &quot;Icon Title:&quot; with title &quot;Display Dialog&quot; default answer an_icon with icon (path to resource an_icon in bundle ((path to library folder from system domain as string) &amp;amp; &quot;CoreServices:CoreTypes.bundle&quot;) as alias) buttons {&quot;Resume&quot;, &quot;Previous&quot;, &quot;Next&quot;} default button 1)&lt;br /&gt;end pause_view&lt;br /&gt;on handle_quit(an_icon)&lt;br /&gt;	set icon_code to &quot;display dialog \&quot;\&quot; with title \&quot;\&quot; default answer \&quot;\&quot; with icon (path to resource \&quot;&quot; &amp;amp; an_icon &amp;amp; &quot;\&quot; in bundle ((path to library folder from system domain as string) &amp;amp; \&quot;CoreServices:CoreTypes.bundle\&quot;) as alias)&quot;&lt;br /&gt;	display dialog &quot;Sample code for &quot; &amp;amp; quoted form of an_icon with title &quot;Quit&quot; default answer icon_code buttons {&quot;Quit&quot;, &quot;Reveal Icon in Finder&quot;, &quot;Copy Code to Clipboard&quot;} cancel button 1 default button 3&lt;br /&gt;	tell result to set {icon_code, copy_option} to {text returned, button returned}&lt;br /&gt;	if copy_option is &quot;Reveal Icon in Finder&quot; then&lt;br /&gt;		set icon_path to ((path to library folder from system domain as string) &amp;amp; &quot;CoreServices:CoreTypes.bundle:Contents:Resources:&quot; &amp;amp; an_icon) as alias&lt;br /&gt;		tell application &quot;Finder&quot;&lt;br /&gt;			activate&lt;br /&gt;			set icon_window to make new Finder window&lt;br /&gt;			tell icon_window&lt;br /&gt;				set target to icon_path&lt;br /&gt;				set current view to icon view&lt;br /&gt;				set toolbar visible to false&lt;br /&gt;			end tell&lt;br /&gt;			tell icon view options of icon_window&lt;br /&gt;				set arrangement to arranged by name&lt;br /&gt;				set shows icon preview to true&lt;br /&gt;				set icon size to 128&lt;br /&gt;			end tell&lt;br /&gt;			reveal icon_path&lt;br /&gt;		end tell&lt;br /&gt;	else if copy_option is &quot;Copy Code to Clipboard&quot; then&lt;br /&gt;		set the clipboard to icon_code&lt;br /&gt;	end if&lt;br /&gt;end handle_quit&lt;br /&gt;to contact_mike(script_revision)&lt;br /&gt;	open location &quot;mailto:mike.com@mac.com?subject=&quot; &amp;amp; script_revision&lt;br /&gt;	error number -128&lt;br /&gt;end contact_mike&lt;/pre&gt;</description>
  <comments>http://automagical.livejournal.com/4092.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://automagical.livejournal.com/3648.html</guid>
  <pubDate>Thu, 08 Dec 2005 19:13:54 GMT</pubDate>
  <title>Fun with hijacking command parameters</title>
  <link>http://automagical.livejournal.com/3648.html</link>
  <description>So I discovered an exciting new behavior in AppleScript today.  That is you can &apos;hijack&apos; commands and make them do pretty much whatever you want, including the command that they&apos;re intended to do. I&apos;m not sure what exactly this is useful for, but it&apos;s a lot of fun!&lt;br /&gt;&lt;br /&gt;click here to &lt;a href=&quot;applescript://com.apple.scripteditor?action=new&amp;amp;script=beep%202%0D%0Don%20beep%20x%0D%09say%20%22So%2C%20you%20want%20me%20to%20beep%20%22%20%26%20x%20%26%20%22%20times%2C%20eh%3F%22%0D%09delay%203%0D%09continue%20beep%20x%0Dend%20beep%0D%0Don%20delay%20y%0D%09repeat%20y%20times%0D%09%09continue%20delay%201%0D%09%09say%20%22hmmm%22%0D%09end%20repeat%0D%09say%20%22ok%22%0Dend%20delay&quot;&gt;open this script in your editor&lt;/a&gt;&lt;pre style=&quot;font-family: &amp;#39;Monaco&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px&quot;&gt;beep 2&lt;br /&gt;&lt;br /&gt;on beep x&lt;br /&gt;	say &quot;So, you want me to beep &quot; &amp;amp; x &amp;amp; &quot; times, eh?&quot;&lt;br /&gt;	delay 3&lt;br /&gt;	continue beep x&lt;br /&gt;end beep&lt;br /&gt;&lt;br /&gt;on delay y&lt;br /&gt;	repeat y times&lt;br /&gt;		continue delay 1&lt;br /&gt;		say &quot;hmmm&quot;&lt;br /&gt;	end repeat&lt;br /&gt;	say &quot;ok&quot;&lt;br /&gt;end delay&lt;/pre&gt;</description>
  <comments>http://automagical.livejournal.com/3648.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>3</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://automagical.livejournal.com/3362.html</guid>
  <pubDate>Mon, 28 Nov 2005 02:24:12 GMT</pubDate>
  <title>Save all Safari Tabs as PDF</title>
  <link>http://automagical.livejournal.com/3362.html</link>
  <description>&lt;a href=&quot;http://forums.macosxhints.com/showthread.php?p=250292&quot;&gt;http://forums.macosxhints.com/showthread.php?p=250292&lt;/a&gt;&lt;br /&gt;&lt;i&gt;Are there any Applescripts that allow me to automate saving to PDF? (In particular saving all open tabs in the browser as PDF files).&lt;/i&gt;&lt;a name=&quot;cutid1&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.macosxhints.com/article.php?story=20031116190809396&quot;&gt;http://www.macosxhints.com/article.php?story=20031116190809396&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The original hint (at the top) is pretty much accurate, except that you hold down the option key not while clicking &apos;Add&apos; but while clicking &apos;More Printers.&apos;  This distinction was made in a more recent comment (at the bottom) of that page.&lt;br /&gt;&lt;br /&gt;click here to &lt;a href=&quot;applescript://com.apple.scripteditor?action=new&amp;amp;script=%28%2A%0DThis%20script%20cycles%20through%20Safari%20tabs%2C%20and%0Dprints%20each%20page%20to%20a%20virtual%20PDF%20printer.%0D%0DTo%20set%20up%20a%20PDF%20printer%20in%20OS%20X%2C%20follow%0Dthe%20instructions%20on%20this%20page%3A%0D%0Dhttp%3A//www.macosxhints.com/article.php%3Fstory%3D20031116190809396%0D%2A%29%0D%0Dset%20printer_name%20to%20%22PDFWriter%22%0Dset%20print_history%20to%20%7B%7D%0D%0Dif%20check_gui%28%29%20is%20true%20then%0D%09activate%20application%20%22Safari%22%0D%09repeat%0D%09%09tell%20application%20%22Safari%22%0D%09%09%09set%20this_page%20to%20URL%20of%20document%201%0D%09%09%09if%20this_page%20is%20not%20in%20print_history%20then%0D%09%09%09%09copy%20this_page%20to%20the%20end%20of%20print_history%0D%09%09%09%09print%20the%20front%20document%20with%20properties%20%7Btarget%20printer%3Aprinter_name%7D%20without%20print%20dialog%0D%09%09%09%09tell%20application%20%22System%20Events%22%20to%20tell%20front%20menu%20bar%20of%20application%20process%20%22Safari%22%0D%09%09%09%09%09click%20menu%20item%20%22Select%20Next%20Tab%22%20of%20front%20menu%20of%20menu%20bar%20item%20%22Window%22%0D%09%09%09%09end%20tell%0D%09%09%09else%0D%09%09%09%09exit%20repeat%0D%09%09%09end%20if%0D%09%09end%20tell%0D%09end%20repeat%0Dend%20if%0D%0D%0Don%20check_gui%28%29%0D%09tell%20application%20%22System%20Events%22%0D%09%09get%20system%20attribute%20%22sysv%22%0D%09%09if%20result%20is%20greater%20than%20or%20equal%20to%204144%20then%20--%20Mac%20OS%20X%2010.3.0%0D%09%09%09if%20UI%20elements%20enabled%20then%0D%09%09%09%09return%20true%0D%09%09%09else%0D%09%09%09%09beep%0D%09%09%09%09display%20dialog%20%22GUI%20Scripting%20is%20not%20enabled%22%20%26%20return%20%26%20return%20%26%20%22Open%20System%20Preferences%20and%20check%20Enable%20Access%20for%20Assistive%20Devices%20in%20the%20Universal%20Access%20preference%20pane%2C%20then%20run%20this%20script%20again.%22%20with%20icon%20stop%0D%09%09%09%09if%20button%20returned%20of%20result%20is%20%22OK%22%20then%0D%09%09%09%09%09tell%20application%20%22System%20Preferences%22%0D%09%09%09%09%09%09activate%0D%09%09%09%09%09%09set%20current%20pane%20to%20pane%20%22com.apple.preference.universalaccess%22%0D%09%09%09%09%09end%20tell%0D%09%09%09%09end%20if%0D%09%09%09end%20if%0D%09%09else%0D%09%09%09beep%0D%09%09%09display%20dialog%20%22This%20computer%20cannot%20run%20this%20script%22%20%26%20return%20%26%20return%20%26%20%22The%20script%20uses%20GUI%20Scripting%20technology%2C%20which%20requires%20an%20upgrade%20to%20Mac%20OS%20X%2010.3%20Panther%20or%20newer.%22%20with%20icon%20caution%20buttons%20%7B%22Quit%22%7D%20default%20button%20%22Quit%22%0D%09%09end%20if%0D%09%09return%20false%0D%09end%20tell%0Dend%20check_gui&quot;&gt;open this script in your editor&lt;/a&gt;&lt;pre style=&quot;font-family: &amp;#39;Monaco&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px&quot;&gt;(*&lt;br /&gt;This script cycles through Safari tabs, and&lt;br /&gt;prints each page to a virtual PDF printer.&lt;br /&gt;&lt;br /&gt;To set up a PDF printer in OS X, follow&lt;br /&gt;the instructions on this page:&lt;br /&gt;&lt;br /&gt;http://www.macosxhints.com/article.php?story=20031116190809396&lt;br /&gt;*)&lt;br /&gt;&lt;br /&gt;set printer_name to &quot;PDFWriter&quot;&lt;br /&gt;set print_history to {}&lt;br /&gt;&lt;br /&gt;if check_gui() is true then&lt;br /&gt;	activate application &quot;Safari&quot;&lt;br /&gt;	repeat&lt;br /&gt;		tell application &quot;Safari&quot;&lt;br /&gt;			set this_page to URL of document 1&lt;br /&gt;			if this_page is not in print_history then&lt;br /&gt;				copy this_page to the end of print_history&lt;br /&gt;				print the front document with properties {target printer:printer_name} without print dialog&lt;br /&gt;				tell application &quot;System Events&quot; to tell front menu bar of application process &quot;Safari&quot;&lt;br /&gt;					click menu item &quot;Select Next Tab&quot; of front menu of menu bar item &quot;Window&quot;&lt;br /&gt;				end tell&lt;br /&gt;			else&lt;br /&gt;				exit repeat&lt;br /&gt;			end if&lt;br /&gt;		end tell&lt;br /&gt;	end repeat&lt;br /&gt;end if&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;on check_gui()&lt;br /&gt;	tell application &quot;System Events&quot;&lt;br /&gt;		get system attribute &quot;sysv&quot;&lt;br /&gt;		if result is greater than or equal to 4144 then -- Mac OS X 10.3.0&lt;br /&gt;			if UI elements enabled then&lt;br /&gt;				return true&lt;br /&gt;			else&lt;br /&gt;				beep&lt;br /&gt;				display dialog &quot;GUI Scripting is not enabled&quot; &amp;amp; return &amp;amp; return &amp;amp; &quot;Open System Preferences and check Enable Access for Assistive Devices in the Universal Access preference pane, then run this script again.&quot; with icon stop&lt;br /&gt;				if button returned of result is &quot;OK&quot; then&lt;br /&gt;					tell application &quot;System Preferences&quot;&lt;br /&gt;						activate&lt;br /&gt;						set current pane to pane &quot;com.apple.preference.universalaccess&quot;&lt;br /&gt;					end tell&lt;br /&gt;				end if&lt;br /&gt;			end if&lt;br /&gt;		else&lt;br /&gt;			beep&lt;br /&gt;			display dialog &quot;This computer cannot run this script&quot; &amp;amp; return &amp;amp; return &amp;amp; &quot;The script uses GUI Scripting technology, which requires an upgrade to Mac OS X 10.3 Panther or newer.&quot; with icon caution buttons {&quot;Quit&quot;} default button &quot;Quit&quot;&lt;br /&gt;		end if&lt;br /&gt;		return false&lt;br /&gt;	end tell&lt;br /&gt;end check_gui&lt;/pre&gt;</description>
  <comments>http://automagical.livejournal.com/3362.html</comments>
  <category>pdf</category>
  <category>save</category>
  <category>safari</category>
  <lj:security>public</lj:security>
  <lj:reply-count>1</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://automagical.livejournal.com/3095.html</guid>
  <pubDate>Mon, 28 Nov 2005 02:19:33 GMT</pubDate>
  <title>Internet Connect GUI Script for 802.1x</title>
  <link>http://automagical.livejournal.com/3095.html</link>
  <description>Is there a way to script a new 802.1x connection in internet connect?&lt;br /&gt;&lt;a href=&quot;http://discussions.apple.com/message.jspa?messageID=1209683&quot;&gt;http://discussions.apple.com/message.jspa?messageID=1209683&lt;/a&gt;&lt;br /&gt;&lt;a name=&quot;cutid1&quot;&gt;&lt;/a&gt;&lt;br /&gt;click here to &lt;a href=&quot;applescript://com.apple.scripteditor?action=new&amp;amp;script=--%20Adjust%20these%20values%20to%20taste%3A%0Dset%20my_description%20to%20%22Foobar%20Conf%22%0Dset%20my_configuration%20to%20%22Other%22%0Dset%20my_network_port%20to%20%22AirPort%22%0Dset%20my_username%20to%20%22foo%22%0Dset%20my_password%20to%20%22bar%22%0Dset%20my_wireless_network%20to%20%22foobar%22%0D--%0Dif%20check_gui%28%29%20is%20false%20then%20error%20number%20-128%0Dactivate%20application%20%22Internet%20Connect%22%0Dtell%20application%20%22System%20Events%22%0D%09tell%20the%20front%20window%20of%20process%20%22Internet%20Connect%22%0D%09%09click%20button%20%22802.1X%22%20of%20the%20first%20tool%20bar%0D%09%09tell%20the%202nd%20pop%20up%20button%0D%09%09%09click%0D%09%09%09click%20menu%20item%20my_configuration%20of%20the%20front%20menu%0D%09%09end%20tell%0D%09%09tell%20the%201st%20pop%20up%20button%0D%09%09%09click%0D%09%09%09click%20menu%20item%20my_network_port%20of%20the%20front%20menu%0D%09%09end%20tell%0D%09%09copy%20my_username%20to%20the%20value%20of%20the%202nd%20text%20field%0D%09%09copy%20my_wireless_network%20to%20the%20value%20of%20the%20first%20combo%20box%0D%09end%20tell%0D%09keystroke%20tab%0D%09key%20code%20123%0D%09repeat%20with%20x%20from%201%20to%20the%20length%20of%20my_password%0D%09%09keystroke%20character%20x%20of%20my_password%0D%09end%20repeat%0D%09tell%20the%20front%20window%20of%20process%20%22Internet%20Connect%22%0D%09%09click%20button%20%22Summary%22%20of%20the%20first%20tool%20bar%0D%09%09tell%20the%20front%20sheet%0D%09%09%09copy%20my_description%20to%20the%20value%20of%20the%20first%20text%20field%0D%09%09%09click%20button%20%22Save%22%0D%09%09end%20tell%0D%09end%20tell%0Dend%20tell%0Dquit%20application%20%22Internet%20Connect%22%0D--%0Don%20check_gui%28%29%0D%09tell%20application%20%22System%20Events%22%0D%09%09get%20system%20attribute%20%22sysv%22%0D%09%09if%20result%20is%20greater%20than%20or%20equal%20to%204144%20then%20--%20Mac%20OS%20X%2010.3.0%0D%09%09%09if%20UI%20elements%20enabled%20then%0D%09%09%09%09return%20true%0D%09%09%09else%0D%09%09%09%09beep%0D%09%09%09%09display%20dialog%20%22GUI%20Scripting%20is%20not%20enabled%22%20%26%20return%20%26%20return%20%26%20%22Open%20System%20Preferences%20and%20check%20Enable%20Access%20for%20Assistive%20Devices%20in%20the%20Universal%20Access%20preference%20pane%2C%20then%20run%20this%20script%20again.%22%20with%20icon%20stop%0D%09%09%09%09if%20button%20returned%20of%20result%20is%20%22OK%22%20then%0D%09%09%09%09%09tell%20application%20%22System%20Preferences%22%0D%09%09%09%09%09%09activate%0D%09%09%09%09%09%09set%20current%20pane%20to%20pane%20%22com.apple.preference.universalaccess%22%0D%09%09%09%09%09end%20tell%0D%09%09%09%09end%20if%0D%09%09%09end%20if%0D%09%09else%0D%09%09%09beep%0D%09%09%09display%20dialog%20%22This%20computer%20cannot%20run%20this%20script%22%20%26%20return%20%26%20return%20%26%20%22The%20script%20uses%20GUI%20Scripting%20technology%2C%20which%20requires%20an%20upgrade%20to%20Mac%20OS%20X%2010.3%20Panther%20or%20newer.%22%20with%20icon%20caution%20buttons%20%7B%22Quit%22%7D%20default%20button%20%22Quit%22%0D%09%09end%20if%0D%09%09return%20false%0D%09end%20tell%0Dend%20check_gui&quot;&gt;open this script in your editor&lt;/a&gt;&lt;pre style=&quot;font-family: &amp;#39;Monaco&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px&quot;&gt;-- Adjust these values to taste:&lt;br /&gt;set my_description to &quot;Foobar Conf&quot;&lt;br /&gt;set my_configuration to &quot;Other&quot;&lt;br /&gt;set my_network_port to &quot;AirPort&quot;&lt;br /&gt;set my_username to &quot;foo&quot;&lt;br /&gt;set my_password to &quot;bar&quot;&lt;br /&gt;set my_wireless_network to &quot;foobar&quot;&lt;br /&gt;--&lt;br /&gt;if check_gui() is false then error number -128&lt;br /&gt;activate application &quot;Internet Connect&quot;&lt;br /&gt;tell application &quot;System Events&quot;&lt;br /&gt;	tell the front window of process &quot;Internet Connect&quot;&lt;br /&gt;		click button &quot;802.1X&quot; of the first tool bar&lt;br /&gt;		tell the 2nd pop up button&lt;br /&gt;			click&lt;br /&gt;			click menu item my_configuration of the front menu&lt;br /&gt;		end tell&lt;br /&gt;		tell the 1st pop up button&lt;br /&gt;			click&lt;br /&gt;			click menu item my_network_port of the front menu&lt;br /&gt;		end tell&lt;br /&gt;		copy my_username to the value of the 2nd text field&lt;br /&gt;		copy my_wireless_network to the value of the first combo box&lt;br /&gt;	end tell&lt;br /&gt;	keystroke tab&lt;br /&gt;	key code 123&lt;br /&gt;	repeat with x from 1 to the length of my_password&lt;br /&gt;		keystroke character x of my_password&lt;br /&gt;	end repeat&lt;br /&gt;	tell the front window of process &quot;Internet Connect&quot;&lt;br /&gt;		click button &quot;Summary&quot; of the first tool bar&lt;br /&gt;		tell the front sheet&lt;br /&gt;			copy my_description to the value of the first text field&lt;br /&gt;			click button &quot;Save&quot;&lt;br /&gt;		end tell&lt;br /&gt;	end tell&lt;br /&gt;end tell&lt;br /&gt;quit application &quot;Internet Connect&quot;&lt;br /&gt;--&lt;br /&gt;on check_gui()&lt;br /&gt;	tell application &quot;System Events&quot;&lt;br /&gt;		get system attribute &quot;sysv&quot;&lt;br /&gt;		if result is greater than or equal to 4144 then -- Mac OS X 10.3.0&lt;br /&gt;			if UI elements enabled then&lt;br /&gt;				return true&lt;br /&gt;			else&lt;br /&gt;				beep&lt;br /&gt;				display dialog &quot;GUI Scripting is not enabled&quot; &amp;amp; return &amp;amp; return &amp;amp; &quot;Open System Preferences and check Enable Access for Assistive Devices in the Universal Access preference pane, then run this script again.&quot; with icon stop&lt;br /&gt;				if button returned of result is &quot;OK&quot; then&lt;br /&gt;					tell application &quot;System Preferences&quot;&lt;br /&gt;						activate&lt;br /&gt;						set current pane to pane &quot;com.apple.preference.universalaccess&quot;&lt;br /&gt;					end tell&lt;br /&gt;				end if&lt;br /&gt;			end if&lt;br /&gt;		else&lt;br /&gt;			beep&lt;br /&gt;			display dialog &quot;This computer cannot run this script&quot; &amp;amp; return &amp;amp; return &amp;amp; &quot;The script uses GUI Scripting technology, which requires an upgrade to Mac OS X 10.3 Panther or newer.&quot; with icon caution buttons {&quot;Quit&quot;} default button &quot;Quit&quot;&lt;br /&gt;		end if&lt;br /&gt;		return false&lt;br /&gt;	end tell&lt;br /&gt;end check_gui&lt;/pre&gt;</description>
  <comments>http://automagical.livejournal.com/3095.html</comments>
  <category>802.1x</category>
  <category>internet connect</category>
  <category>gui</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://automagical.livejournal.com/2994.html</guid>
  <pubDate>Sun, 27 Nov 2005 19:39:17 GMT</pubDate>
  <title>Sticky Note Mail Rule</title>
  <link>http://automagical.livejournal.com/2994.html</link>
  <description>&lt;i&gt;&quot;I want to be able to email notes to a certain email address and then, when I get home and check my mail, have each of those emails turned into a brand-new sticky note on my desktop.&quot;-&lt;span class=&apos;ljuser ljuser-name_nightbird&apos; lj:user=&apos;nightbird&apos; style=&apos;white-space: nowrap;&apos;&gt;&lt;a href=&apos;http://nightbird.livejournal.com/profile&apos;&gt;&lt;img src=&apos;http://l-stat.livejournal.com/img/userinfo.gif&apos; alt=&apos;[info]&apos; width=&apos;17&apos; height=&apos;17&apos; style=&apos;vertical-align: bottom; border: 0; padding-right: 1px;&apos; /&gt;&lt;/a&gt;&lt;a href=&apos;http://nightbird.livejournal.com/&apos;&gt;&lt;b&gt;nightbird&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;a href=&quot;http://www.livejournal.com/community/applescript/20620.html?style=mine&quot;&gt;http://www.livejournal.com/community/applescript/20620.html?style=mine&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name=&quot;cutid1&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;click here to &lt;a href=&quot;applescript://com.apple.scripteditor?action=new&amp;amp;script=--%20contact_mike%28%22Sticky_Note_Mail_Rule_0.2.1%22%29%20--%20composes%20mail%20to%20the%20author%20and%20cancels%20script%0Dusing%20terms%20from%20application%20%22Mail%22%0D%09on%20perform%20mail%20action%20with%20messages%20the_messages%0D%09%09try%0D%09%09%09set%20rule_folder%20to%20%22Stickies%22%0D%09%09%09tell%20application%20%22Mail%22%0D%09%09%09%09repeat%20with%20a_message%20in%20the_messages%0D%09%09%09%09%09set%20a_note%20to%20%22%22%0D%09%09%09%09%09repeat%20with%20x%20from%201%20to%205%0D%09%09%09%09%09%09set%20a_note%20to%20paragraph%20x%20of%20a_message%27s%20content%20as%20Unicode%20text%0D%09%09%09%09%09%09if%20a_note%20is%20not%20%22%22%20then%20exit%20repeat%0D%09%09%09%09%09end%20repeat%0D%09%09%09%09%09set%20the%20clipboard%20to%20a_note%0D%09%09%09%09%09activate%20application%20%22Stickies%22%0D%09%09%09%09%09if%20check_gui%28%29%20of%20me%20is%20false%20then%20error%20number%20-128%0D%09%09%09%09%09tell%20application%20%22System%20Events%22%20to%20tell%20the%20front%20menu%20bar%20of%20process%20%22Stickies%22%0D%09%09%09%09%09%09click%20menu%20item%20%22New%20Note%22%20of%20the%20front%20menu%20of%20menu%20bar%20item%20%22File%22%0D%09%09%09%09%09%09tell%20the%20front%20menu%20of%20menu%20bar%20item%20%22Edit%22%0D%09%09%09%09%09%09%09click%20menu%20item%20%22Check%20Spelling%20as%20You%20Type%22%20of%20the%20front%20menu%20of%20menu%20item%20%22Spelling%22%0D%09%09%09%09%09%09%09click%20menu%20item%20%22Paste%22%0D%09%09%09%09%09%09end%20tell%0D%09%09%09%09%09end%20tell%0D%09%09%09%09%09set%20the%20read%20status%20of%20a_message%20to%20true%0D%09%09%09%09%09move%20a_message%20to%20the%20mailbox%20%22Trash%22%0D%09%09%09%09end%20repeat%0D%09%09%09end%20tell%0D%09%09on%20error%20the%20error_message%20number%20the%20error_number%0D%09%09%09tell%20me%20to%20activate%0D%09%09%09set%20error_msg%20to%20%22Error%3A%20%22%20%26%20the%20error_number%20%26%20%22.%20%22%20%26%20the%20error_message%0D%09%09%09display%20dialog%20error_msg%20buttons%20%7B%22Cancel%22%2C%20%22Copy%20Error%20to%20Clipboard%22%7D%20default%20button%202%0D%09%09%09set%20the%20clipboard%20to%20error_msg%0D%09%09end%20try%0D%09end%20perform%20mail%20action%20with%20messages%0Dend%20using%20terms%20from%0Don%20check_gui%28%29%0D%09tell%20application%20%22System%20Events%22%0D%09%09get%20system%20attribute%20%22sysv%22%0D%09%09if%20result%20is%20greater%20than%20or%20equal%20to%204144%20then%20--%20Mac%20OS%20X%2010.3.0%0D%09%09%09if%20UI%20elements%20enabled%20then%0D%09%09%09%09return%20true%0D%09%09%09else%0D%09%09%09%09beep%0D%09%09%09%09display%20dialog%20%22GUI%20Scripting%20is%20not%20enabled%22%20%26%20return%20%26%20return%20%26%20%22Open%20System%20Preferences%20and%20check%20Enable%20Access%20for%20Assistive%20Devices%20in%20the%20Universal%20Access%20preference%20pane%2C%20then%20run%20this%20script%20again.%22%20with%20icon%20stop%0D%09%09%09%09if%20button%20returned%20of%20result%20is%20%22OK%22%20then%0D%09%09%09%09%09tell%20application%20%22System%20Preferences%22%0D%09%09%09%09%09%09activate%0D%09%09%09%09%09%09set%20current%20pane%20to%20pane%20%22com.apple.preference.universalaccess%22%0D%09%09%09%09%09end%20tell%0D%09%09%09%09end%20if%0D%09%09%09end%20if%0D%09%09else%0D%09%09%09beep%0D%09%09%09display%20dialog%20%22This%20computer%20cannot%20run%20this%20script%22%20%26%20return%20%26%20return%20%26%20%22The%20script%20uses%20GUI%20Scripting%20technology%2C%20which%20requires%20an%20upgrade%20to%20Mac%20OS%20X%2010.3%20Panther%20or%20newer.%22%20with%20icon%20caution%20buttons%20%7B%22Quit%22%7D%20default%20button%20%22Quit%22%0D%09%09end%20if%0D%09%09return%20false%0D%09end%20tell%0Dend%20check_gui%0Dto%20contact_mike%28script_revision%29%0D%09open%20location%20%22mailto%3Amike.com%40mac.com%3Fsubject%3D%22%20%26%20script_revision%0D%09error%20number%20-128%0Dend%20contact_mike&quot;&gt;open this script in your editor&lt;/a&gt;&lt;pre style=&quot;font-family: &amp;#39;Monaco&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px&quot;&gt;-- contact_mike(&quot;Sticky_Note_Mail_Rule_0.2.1&quot;) -- composes mail to the author and cancels script&lt;br /&gt;using terms from application &quot;Mail&quot;&lt;br /&gt;	on perform mail action with messages the_messages&lt;br /&gt;		try&lt;br /&gt;			set rule_folder to &quot;Stickies&quot;&lt;br /&gt;			tell application &quot;Mail&quot;&lt;br /&gt;				repeat with a_message in the_messages&lt;br /&gt;					set a_note to &quot;&quot;&lt;br /&gt;					repeat with x from 1 to 5&lt;br /&gt;						set a_note to paragraph x of a_message&apos;s content as Unicode text&lt;br /&gt;						if a_note is not &quot;&quot; then exit repeat&lt;br /&gt;					end repeat&lt;br /&gt;					set the clipboard to a_note&lt;br /&gt;					activate application &quot;Stickies&quot;&lt;br /&gt;					if check_gui() of me is false then error number -128&lt;br /&gt;					tell application &quot;System Events&quot; to tell the front menu bar of process &quot;Stickies&quot;&lt;br /&gt;						click menu item &quot;New Note&quot; of the front menu of menu bar item &quot;File&quot;&lt;br /&gt;						tell the front menu of menu bar item &quot;Edit&quot;&lt;br /&gt;							click menu item &quot;Check Spelling as You Type&quot; of the front menu of menu item &quot;Spelling&quot;&lt;br /&gt;							click menu item &quot;Paste&quot;&lt;br /&gt;						end tell&lt;br /&gt;					end tell&lt;br /&gt;					set the read status of a_message to true&lt;br /&gt;					move a_message to the mailbox &quot;Trash&quot;&lt;br /&gt;				end repeat&lt;br /&gt;			end tell&lt;br /&gt;		on error the error_message number the error_number&lt;br /&gt;			tell me to activate&lt;br /&gt;			set error_msg to &quot;Error: &quot; &amp;amp; the error_number &amp;amp; &quot;. &quot; &amp;amp; the error_message&lt;br /&gt;			display dialog error_msg buttons {&quot;Cancel&quot;, &quot;Copy Error to Clipboard&quot;} default button 2&lt;br /&gt;			set the clipboard to error_msg&lt;br /&gt;		end try&lt;br /&gt;	end perform mail action with messages&lt;br /&gt;end using terms from&lt;br /&gt;on check_gui()&lt;br /&gt;	tell application &quot;System Events&quot;&lt;br /&gt;		get system attribute &quot;sysv&quot;&lt;br /&gt;		if result is greater than or equal to 4144 then -- Mac OS X 10.3.0&lt;br /&gt;			if UI elements enabled then&lt;br /&gt;				return true&lt;br /&gt;			else&lt;br /&gt;				beep&lt;br /&gt;				display dialog &quot;GUI Scripting is not enabled&quot; &amp;amp; return &amp;amp; return &amp;amp; &quot;Open System Preferences and check Enable Access for Assistive Devices in the Universal Access preference pane, then run this script again.&quot; with icon stop&lt;br /&gt;				if button returned of result is &quot;OK&quot; then&lt;br /&gt;					tell application &quot;System Preferences&quot;&lt;br /&gt;						activate&lt;br /&gt;						set current pane to pane &quot;com.apple.preference.universalaccess&quot;&lt;br /&gt;					end tell&lt;br /&gt;				end if&lt;br /&gt;			end if&lt;br /&gt;		else&lt;br /&gt;			beep&lt;br /&gt;			display dialog &quot;This computer cannot run this script&quot; &amp;amp; return &amp;amp; return &amp;amp; &quot;The script uses GUI Scripting technology, which requires an upgrade to Mac OS X 10.3 Panther or newer.&quot; with icon caution buttons {&quot;Quit&quot;} default button &quot;Quit&quot;&lt;br /&gt;		end if&lt;br /&gt;		return false&lt;br /&gt;	end tell&lt;br /&gt;end check_gui&lt;br /&gt;to contact_mike(script_revision)&lt;br /&gt;	open location &quot;mailto:mike.com@mac.com?subject=&quot; &amp;amp; script_revision&lt;br /&gt;	error number -128&lt;br /&gt;end contact_mike&lt;/pre&gt;</description>
  <comments>http://automagical.livejournal.com/2994.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>6</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://automagical.livejournal.com/2602.html</guid>
  <pubDate>Fri, 18 Nov 2005 19:02:00 GMT</pubDate>
  <title>Detect sound activity with AppleScript</title>
  <link>http://automagical.livejournal.com/2602.html</link>
  <description>&lt;a href=&quot;http://bbs.applescript.net/viewtopic.php?id=14969&quot;&gt;Wake display with a sound, any sound.&lt;/a&gt;&lt;br /&gt;&quot;how can I use the integrated microphone for to wake the screen any time a nois is detected and keep it on until a no noise is detected for a certain amount od time?&quot;&lt;br /&gt;&lt;br /&gt;There may be a better way to do this, but the first thing that came to my mind was VOX voice-activated recording apps.  The one I test here is the shareware Audiocorder 4.5 [USD$20] you can download a demo here:&lt;br /&gt;&lt;a href=&quot;http://www.versiontracker.com/dyn/moreinfo/macosx/10417&quot;&gt;http://www.versiontracker.com/dyn/moreinfo/macosx/10417&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Edit: The following script is an applet because I was originally attempting to monitor audiocorder&apos;s gui for the trigger. It seems however that the GUI is unavailable during a screensaver/display sleep event. The script in its present form could be easily written as a folder action, which would cause less performance issues.&lt;a name=&quot;cutid1&quot;&gt;&lt;/a&gt;&lt;br /&gt;All I did was save the following code as a &apos;stay-open application&apos; with Script Editor, and then left it running while Audiocorder was set to &apos;VOX&apos; mode.&amp;nbsp; The moment the VOX audio threshold was exceeded it created a new audio file, which the script detected immediately and woke the display.&lt;br /&gt;&lt;br /&gt;Please note that this script assumes that you&apos;ve enabled &lt;strong&gt;access for assistive devices&lt;/strong&gt; on the universal access pane of system preferences, and that you&apos;ve selected &lt;strong&gt;require password to wake this computer from sleep or screen saver&lt;/strong&gt; on the security pane of system preferences.&lt;br /&gt;&lt;br /&gt;click here to &lt;a href=&quot;applescript://com.apple.scripteditor?action=new&amp;amp;script=property%20old_count%20%3A%20integer%0Dset%20the%20old_count%20to%20the%20new_count%28%29%0D%0Don%20idle%0D%09if%20the%20new_count%28%29%20is%20greater%20than%20the%20old_count%20then%0D%09%09set%20the%20old_count%20to%20the%20new_count%28%29%0D%09%09tell%20application%20%22System%20Events%22%0D%09%09%09key%20code%2053%0D%09%09%09delay%203%0D%09%09%09key%20code%2053%0D%09%09end%20tell%0D%09end%20if%0D%09return%200.5%0Dend%20idle%0D%0Don%20new_count%28%29%0D%09tell%20application%20%22Finder%22%20to%20count%20%28path%20to%20application%20%22Audiocorder%20OSX%22%29%27s%20container%27s%20items%0Dend%20new_count&quot;&gt;open this script in your editor&lt;/a&gt;&lt;pre style=&quot;font-family: &amp;#39;Monaco&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px&quot;&gt;property old_count : integer&lt;br /&gt;set the old_count to the new_count()&lt;br /&gt;&lt;br /&gt;on idle&lt;br /&gt;	if the new_count() is greater than the old_count then&lt;br /&gt;		set the old_count to the new_count()&lt;br /&gt;		tell application &quot;System Events&quot;&lt;br /&gt;			key code 53&lt;br /&gt;			delay 3&lt;br /&gt;			key code 53&lt;br /&gt;		end tell&lt;br /&gt;	end if&lt;br /&gt;	return 0.5&lt;br /&gt;end idle&lt;br /&gt;&lt;br /&gt;on new_count()&lt;br /&gt;	tell application &quot;Finder&quot; to count (path to application &quot;Audiocorder OSX&quot;)&apos;s container&apos;s items&lt;br /&gt;end new_count&lt;/pre&gt;</description>
  <comments>http://automagical.livejournal.com/2602.html</comments>
  <category>display</category>
  <category>screensaver</category>
  <category>vox</category>
  <category>sleep</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://automagical.livejournal.com/2417.html</guid>
  <pubDate>Fri, 18 Nov 2005 18:49:41 GMT</pubDate>
  <title>Extract text from complex web sites</title>
  <link>http://automagical.livejournal.com/2417.html</link>
  <description>&lt;a href=&quot;http://lists.apple.com/archives/applescript-users/2005/Nov/msg00403.html&quot;&gt;Re: Web text to word&lt;/a&gt;&lt;br /&gt;&quot;I want to copy all the text in my current safari web page and put it into ms word.&quot;&lt;br /&gt;&lt;br /&gt;I thought this would be a simple thing to do, and it may be simple in Word 2004, but I only have Word v.X, and everything I tried was either failing entirely, failing half the time, or producing garbled results.  The only clean way I found to accomplish this task on my machine was to pass the text through both TextEdit and 10.4 Tiger&apos;s &apos;textutil&apos; before opening a temporary file in Word.  This isn&apos;t a particularly concise script, nor is it terribly obvious, but it works, and the results are on par with what you&apos;d get using Word&apos;s &apos;paste special&apos; feature.&lt;a name=&quot;cutid1&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;click here to &lt;a href=&quot;applescript://com.apple.scripteditor?action=new&amp;amp;script=%22/tmp/my_doc.txt%22%0Dset%20my_file%20to%20POSIX%20file%20result%0Dtell%20application%20%22Safari%22%0D%09open%20location%20%22http%3A//news.google.com/%22%0D%09delay%205%20--%20wait%20for%20page%20to%20load%2C%20adjust%20as%20needed%0D%09set%20my_text%20to%20the%20text%20of%20the%20front%20document%0Dend%20tell%0Dtell%20application%20%22TextEdit%22%0D%09--%20NOTE%3A%20this%20step%20only%20works%20correctly%20if%20you%27ve%20set%20TextEdit%0D%09--%20preferences%20to%20use%20%27Plain%20Text%27%20for%20the%20new%20document%20format.%0D%09set%20my_doc%20to%20make%20new%20document%20with%20properties%20%7Btext%3Amy_text%7D%0D%09close%20my_doc%20saving%20in%20my_file%0Dend%20tell%0Ddo%20shell%20script%20%22cd%20/tmp%3B%20textutil%20-convert%20rtf%20-font%20Times%20-fontsize%2010%20my_doc.txt%22%0D%22/tmp/my_doc.rtf%22%0Dset%20my_file%20to%20POSIX%20file%20result%0Dtell%20application%20%22Microsoft%20Word%22%20to%20open%20my_file&quot;&gt;open this script in your editor&lt;/a&gt;&lt;pre style=&quot;font-family: &amp;#39;Monaco&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px&quot;&gt;&quot;/tmp/my_doc.txt&quot;&lt;br /&gt;set my_file to POSIX file result&lt;br /&gt;tell application &quot;Safari&quot;&lt;br /&gt;	open location &quot;http://news.google.com/&quot;&lt;br /&gt;	delay 5 -- wait for page to load, adjust as needed&lt;br /&gt;	set my_text to the text of the front document&lt;br /&gt;end tell&lt;br /&gt;tell application &quot;TextEdit&quot;&lt;br /&gt;	-- NOTE: this step only works correctly if you&apos;ve set TextEdit&lt;br /&gt;	-- preferences to use &apos;Plain Text&apos; for the new document format.&lt;br /&gt;	set my_doc to make new document with properties {text:my_text}&lt;br /&gt;	close my_doc saving in my_file&lt;br /&gt;end tell&lt;br /&gt;do shell script &quot;cd /tmp; textutil -convert rtf -font Times -fontsize 10 my_doc.txt&quot;&lt;br /&gt;&quot;/tmp/my_doc.rtf&quot;&lt;br /&gt;set my_file to POSIX file result&lt;br /&gt;tell application &quot;Microsoft Word&quot; to open my_file&lt;/pre&gt;</description>
  <comments>http://automagical.livejournal.com/2417.html</comments>
  <category>office</category>
  <category>textutil</category>
  <category>word</category>
  <category>textedit</category>
  <category>safari</category>
  <category>shell</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://automagical.livejournal.com/2165.html</guid>
  <pubDate>Fri, 18 Nov 2005 18:43:16 GMT</pubDate>
  <title>Script iChat login accounts</title>
  <link>http://automagical.livejournal.com/2165.html</link>
  <description>&lt;a href=&quot;http://lists.apple.com/archives/applescript-users/2005/Nov/msg00395.html&quot;&gt;Re: Switching iChat Accounts&lt;/a&gt;&lt;br /&gt;On Nov 14, 2005, at 9:36 PM, Ed McNichol wrote:&lt;br /&gt;I have 15 users who share three computers. Each COMPUTER has an iChat account. I want the user logged into the iChat account appropriate for that computer. Users preferences are shared from a network log on. I would like to script this to happen at log on.&lt;br /&gt;&lt;br /&gt;On Nov 15, 2005, at 19:08:08, Dave Lyons wrote:&lt;br /&gt;I don&apos;t know how to make this work, but I got a little bit further.  The dictionary indicates that &quot;log in&quot; takes a reference to the account to be logged in&lt;br /&gt;&lt;br /&gt;From what I can tell this is just a case of a misleading dictionary entry.  The only object I can get iChat&apos;s &apos;log in&apos; command to accept is a reference to the service (AIM, Bonjour, Jabber) that is to be logged into.  Accounts themselves are defined in iChat preferences, and only one can be the &apos;default&apos; account for each service. Here&apos;s a script I wrote that switches between the two AIM accounts that I&apos;ve set up in iChat. Perhaps you can modify this so that it&apos;s useful for your situation.&lt;a name=&quot;cutid1&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;click here to &lt;a href=&quot;applescript://com.apple.scripteditor?action=new&amp;amp;script=tell%20application%20%22iChat%22%20to%20quit%0Dtell%20application%20%22System%20Events%22%0D%09if%20%22iChatAgent%22%20is%20in%20name%20of%20every%20process%20then%20do%20shell%20script%20%22killall%20iChatAgent%22%0D%09tell%20the%20property%20list%20file%20%28%28path%20to%20preferences%20as%20string%29%20%26%20%22com.apple.iChat.AIM.plist%22%29%0D%09%09set%20aim_accounts%20to%20name%20of%20property%20list%20items%20of%20property%20list%20item%20%22Accounts%22%0D%09%09set%20active_account%20to%20value%20of%20property%20list%20item%20%22ActiveAccount%22%0D%09%09repeat%20with%20x%20in%20aim_accounts%0D%09%09%09set%20y%20to%20the%20contents%20of%20x%0D%09%09%09if%20y%20is%20not%20the%20active_account%20then%0D%09%09%09%09copy%20y%20to%20the%20value%20of%20property%20list%20item%20%22ActiveAccount%22%0D%09%09%09end%20if%0D%09%09end%20repeat%0D%09end%20tell%0Dend%20tell%0Dtell%20application%20%22iChat%22%20to%20log%20in%20service%20%22AIM%22&quot;&gt;open this script in your editor&lt;/a&gt;&lt;pre style=&quot;font-family: &amp;#39;Monaco&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px&quot;&gt;tell application &quot;iChat&quot; to quit&lt;br /&gt;tell application &quot;System Events&quot;&lt;br /&gt;	if &quot;iChatAgent&quot; is in name of every process then do shell script &quot;killall iChatAgent&quot;&lt;br /&gt;	tell the property list file ((path to preferences as string) &amp;amp; &quot;com.apple.iChat.AIM.plist&quot;)&lt;br /&gt;		set aim_accounts to name of property list items of property list item &quot;Accounts&quot;&lt;br /&gt;		set active_account to value of property list item &quot;ActiveAccount&quot;&lt;br /&gt;		repeat with x in aim_accounts&lt;br /&gt;			set y to the contents of x&lt;br /&gt;			if y is not the active_account then&lt;br /&gt;				copy y to the value of property list item &quot;ActiveAccount&quot;&lt;br /&gt;			end if&lt;br /&gt;		end repeat&lt;br /&gt;	end tell&lt;br /&gt;end tell&lt;br /&gt;tell application &quot;iChat&quot; to log in service &quot;AIM&quot;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Whereas you could modify the script I just posted to select a particular AIM account to sign into, I just discovered that it&apos;s also possible to get iChat to log in to an arbitrary screen name specified by the script. My method is to overwrite the screen name of the first account in iChat prefs. This is problematic if you want to actually keep that account the way it was, but iChat otherwise handles the new name without a hitch, and even prompts for a new password to store in the keychain.&lt;br /&gt;&lt;br /&gt;click here to &lt;a href=&quot;applescript://com.apple.scripteditor?action=new&amp;amp;script=sign%20on%20%22foo%22%0D%0Dto%20sign%20on%20an_account%0D%09tell%20application%20%22iChat%22%20to%20quit%0D%09tell%20application%20%22System%20Events%22%0D%09%09if%20%22iChatAgent%22%20is%20in%20name%20of%20every%20process%20then%20do%20shell%20script%20%22killall%20iChatAgent%22%0D%09%09tell%20the%20property%20list%20file%20%28%28path%20to%20preferences%20as%20string%29%20%26%20%22com.apple.iChat.AIM.plist%22%29%0D%09%09%09tell%20the%20first%20property%20list%20item%20of%20property%20list%20item%20%22Accounts%22%0D%09%09%09%09copy%20name%20to%20account_id%0D%09%09%09%09copy%20an_account%20to%20the%20value%20of%20property%20list%20item%20%22LoginAs%22%0D%09%09%09end%20tell%0D%09%09%09copy%20account_id%20to%20the%20value%20of%20property%20list%20item%20%22ActiveAccount%22%0D%09%09end%20tell%0D%09end%20tell%0D%09tell%20application%20%22iChat%22%20to%20log%20in%20service%20%22AIM%22%0Dend%20sign&quot;&gt;open this script in your editor&lt;/a&gt;&lt;pre style=&quot;font-family: &amp;#39;Monaco&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px&quot;&gt;sign on &quot;foo&quot;&lt;br /&gt;&lt;br /&gt;to sign on an_account&lt;br /&gt;	tell application &quot;iChat&quot; to quit&lt;br /&gt;	tell application &quot;System Events&quot;&lt;br /&gt;		if &quot;iChatAgent&quot; is in name of every process then do shell script &quot;killall iChatAgent&quot;&lt;br /&gt;		tell the property list file ((path to preferences as string) &amp;amp; &quot;com.apple.iChat.AIM.plist&quot;)&lt;br /&gt;			tell the first property list item of property list item &quot;Accounts&quot;&lt;br /&gt;				copy name to account_id&lt;br /&gt;				copy an_account to the value of property list item &quot;LoginAs&quot;&lt;br /&gt;			end tell&lt;br /&gt;			copy account_id to the value of property list item &quot;ActiveAccount&quot;&lt;br /&gt;		end tell&lt;br /&gt;	end tell&lt;br /&gt;	tell application &quot;iChat&quot; to log in service &quot;AIM&quot;&lt;br /&gt;end sign&lt;/pre&gt;</description>
  <comments>http://automagical.livejournal.com/2165.html</comments>
  <category>system events</category>
  <category>ichat</category>
  <category>preferences</category>
  <lj:security>public</lj:security>
  <lj:reply-count>15</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://automagical.livejournal.com/1862.html</guid>
  <pubDate>Fri, 18 Nov 2005 18:18:11 GMT</pubDate>
  <title>Droplet to compose a Mail message with attachments</title>
  <link>http://automagical.livejournal.com/1862.html</link>
  <description>&lt;a href=&quot;http://discussions.apple.com/thread.jspa?messageID=1220890&quot;&gt;Re: Automator question regarding email&lt;/a&gt;&lt;br /&gt;&quot;I have managed to make an Automator application where if I drag a document onto the action - it opens a new Mail message with that document as the attachment. The action also puts the specified person&apos;s email address in the Mail message&apos;s address box. What I would like to add - is that the NAME of the document which I drag onto the Automator Application, becomes the SUBJECT line of the new Mail message.&quot; &lt;a name=&quot;cutid1&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This may be out of line in an Automator forum, but I think you need an AppleScript to accomplish this. I wrote an AppleScript droplet for you that does what you want, and as an added bonus it will accept drag and drop multiple-item finder selections as well as single-item.  If there is more than one item the script will add each file to the new mail message, and add each file name to the subject as well, separated by commas.&lt;br&gt;&lt;br&gt;To use the script, click the following link to open it in Script Editor, then save it to your hard drive using the &apos;File Format: Application&apos; option in Script Editor&apos;s save dialog.  The three other save options should be left unchecked.&lt;br&gt;&lt;br&gt;click here to &lt;a href=&quot;applescript://com.apple.scripteditor?action=new&amp;amp;script=on%20open%20my_files%0D%09%0D%09--%20change%20the%20following%20variable%20to%20your%20recipient%27s%20adddress%0D%09set%20an_address%20to%20%22jdoe%40apple.com%22%0D%09%0D%09--%20or%2C%20alternatively%2C%20remove%20the%20%27--%27%20from%20the%20next%20line%20to%20get%20a%20dialog%0D%09--%20set%20an_address%20to%20text%20returned%20of%20%28display%20dialog%20%22New%20E-mail%20Recipient%3A%22%20default%20answer%20%22%22%29%0D%09%0D%09set%20my_subject%20to%20%7B%7D%0D%09tell%20application%20%22Finder%22%20to%20repeat%20with%20x%20in%20my_files%0D%09%09set%20my_subject%20to%20my_subject%20%26%20%28name%20of%20contents%20of%20x%29%0D%09end%20repeat%0D%09set%20%7BTID%2C%20text%20item%20delimiters%7D%20to%20%7Btext%20item%20delimiters%2C%20%22%2C%20%22%7D%0D%09set%20%7Bmy_subject%2C%20text%20item%20delimiters%7D%20to%20%7Bmy_subject%20as%20Unicode%20text%2C%20TID%7D%0D%09tell%20application%20%22Mail%22%0D%09%09activate%0D%09%09set%20my_message%20to%20make%20new%20outgoing%20message%20with%20properties%20%7Bsubject%3Amy_subject%7D%0D%09%09tell%20my_message%0D%09%09%09set%20visible%20to%20true%0D%09%09%09make%20new%20to%20recipient%20at%20end%20of%20to%20recipients%20with%20properties%20%7Baddress%3Aan_address%7D%0D%09%09%09repeat%20with%20x%20in%20my_files%0D%09%09%09%09tell%20content%20to%20make%20new%20attachment%20with%20properties%20%7Bfile%20name%3A%28contents%20of%20x%29%7D%20at%20after%20the%20last%20paragraph%0D%09%09%09end%20repeat%0D%09%09%09--%20remove%20the%20%27--%27%20from%20the%20next%20line%20to%20send%20the%20message%20automatically%0D%09%09%09--%20send%0D%09%09end%20tell%0D%09end%20tell%0Dend%20open&quot;&gt;open this script in your editor&lt;/a&gt;&lt;pre style=&quot;font-family: &amp;#39;Monaco&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px&quot;&gt;on open my_files&lt;br /&gt;	&lt;br /&gt;	-- change the following variable to your recipient&apos;s adddress&lt;br /&gt;	set an_address to &quot;jdoe@apple.com&quot;&lt;br /&gt;	&lt;br /&gt;	-- or, alternatively, remove the &apos;--&apos; from the next line to get a dialog&lt;br /&gt;	-- set an_address to text returned of (display dialog &quot;New E-mail Recipient:&quot; default answer &quot;&quot;)&lt;br /&gt;	&lt;br /&gt;	set my_subject to {}&lt;br /&gt;	tell application &quot;Finder&quot; to repeat with x in my_files&lt;br /&gt;		set my_subject to my_subject &amp;amp; (name of contents of x)&lt;br /&gt;	end repeat&lt;br /&gt;	set {TID, text item delimiters} to {text item delimiters, &quot;, &quot;}&lt;br /&gt;	set {my_subject, text item delimiters} to {my_subject as Unicode text, TID}&lt;br /&gt;	tell application &quot;Mail&quot;&lt;br /&gt;		activate&lt;br /&gt;		set my_message to make new outgoing message with properties {subject:my_subject}&lt;br /&gt;		tell my_message&lt;br /&gt;			set visible to true&lt;br /&gt;			make new to recipient at end of to recipients with properties {address:an_address}&lt;br /&gt;			repeat with x in my_files&lt;br /&gt;				tell content to make new attachment with properties {file name:(contents of x)} at after the last paragraph&lt;br /&gt;			end repeat&lt;br /&gt;			-- remove the &apos;--&apos; from the next line to send the message automatically&lt;br /&gt;			-- send&lt;br /&gt;		end tell&lt;br /&gt;	end tell&lt;br /&gt;end open&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here is a significantly updated and enhanced version of this script. It adds in a preference system among other things:&lt;br /&gt;&lt;a name=&quot;cutid2&quot;&gt;&lt;/a&gt;&lt;br /&gt;click here to &lt;a href=&quot;applescript://com.apple.scripteditor?action=new&amp;amp;script=property%20an_address%20%3A%20%22jdoe%40apple.com%22%0Dproperty%20a_name%20%3A%20%22Jane%20Doe%22%0Dproperty%20proj_name%20%3A%20%22Generic%20Project%22%0Dproperty%20hide_ext%20%3A%20%22NO%22%0Dproperty%20auto_send%20%3A%20%22NO%22%0Dproperty%20add_label%20%3A%20%22NO%22%0Dproperty%20a_label%20%3A%20%22%20-%20Final%22%0Dproperty%20add_form%20%3A%20%22NO%22%0Dproperty%20prompt_address%20%3A%20%22NO%22%0Dproperty%20prompt_label%20%3A%20%22NO%22%0Dproperty%20prompt_project%20%3A%20%22NO%22%0Dproperty%20form_letter%20%3A%20%22Hello%20%2ANAME%2A%2C%0D%0DAttached%20are%20the%20files%20for%20%5C%22%2APROJ%2A.%5C%22%0D%0DThank%20you%2C%0DMy%20Name%0D%22%0D%28%2A%20the%20preceding%20are%20merely%20default%20values%2C%20they%0Ddo%20not%20need%20to%20be%20edited%20here%2C%20and%20will%20only%0Dreset%20when%20the%20script%20is%20recompiled%20%2A%29%0Don%20run%0D%09repeat%0D%09%09set%20%7Blabel_preview%2C%20form_preview%7D%20to%20%7B%22NO%20-%20Add%20Label%22%2C%20%22NO%20-%20Add%20Form%20Letter%22%7D%0D%09%09if%20add_label%20is%20%22YES%22%20then%20set%20label_preview%20to%20%22YES%20-%20Add%20Label%20%22%20%26%20quoted%20form%20of%20a_label%0D%09%09if%20add_form%20is%20%22YES%22%20then%20set%20form_preview%20to%20%22YES%20-%20Add%20Form%20Letter%3A%22%20%26%20return%20%26%20return%20%26%20form_letter%0D%09%09%0D%09%09display%20dialog%20%22Recipient%3A%20%22%20%26%20a_name%20%26%20space%20%26%20%28quoted%20form%20of%20an_address%29%20%26%20return%20%26%20%22%0D%22%20%26%20hide_ext%20%26%20%22%20-%20Hide%20File%20Extensions%0D%22%20%26%20auto_send%20%26%20%22%20-%20Auto-Send%0D%22%20%26%20label_preview%20%26%20return%20%26%20form_preview%20%26%20return%20%26%20%22%0DAlways%20Prompt%20for%3A%20%0D%22%20%26%20prompt_address%20%26%20%22%20-%20Recipient%0D%22%20%26%20prompt_label%20%26%20%22%20-%20Label%0D%22%20%26%20prompt_project%20%26%20%22%20-%20Project%22%20with%20title%20%22Script%20Preferences%22%20buttons%20%7B%22Edit%20Recipient%22%2C%20%22Other%20Settings%22%2C%20%22OK%22%7D%20default%20button%203%0D%09%09copy%20button%20returned%20of%20result%20to%20my_option%0D%09%09if%20my_option%20is%20%22Edit%20Recipient%22%20then%0D%09%09%09set%20an_address%20to%20text%20returned%20of%20%28display%20dialog%20%22Edit%20E-mail%20Recipient%3A%22%20default%20answer%20an_address%29%0D%09%09%09display%20dialog%20%22Edit%20Recipient%27s%20Name%3A%22%20default%20answer%20a_name%20buttons%20%7B%22Other%20Settings%22%2C%20%22OK%22%7D%0D%09%09%09copy%20%7Btext%20returned%2C%20button%20returned%7D%20of%20result%20to%20%7Ba_name%2C%20my_option%7D%0D%09%09end%20if%0D%09%09if%20my_option%20is%20%22Other%20Settings%22%20then%0D%09%09%09set%20hide_ext%20to%20button%20returned%20of%20%28display%20dialog%20%22Shall%20the%20script%20hide%20all%20file%20extensions%3F%22%20with%20title%20%22Hide%20File%20Extenstions%22%20buttons%20%7B%22YES%22%2C%20%22NO%22%7D%20default%20button%20def_int%28hide_ext%29%29%0D%09%09%09set%20auto_send%20to%20button%20returned%20of%20%28display%20dialog%20%22Shall%20the%20script%20automatically%20send%20the%20message%20when%20it%20runs%3F%22%20with%20title%20%22Auto-Send%22%20buttons%20%7B%22YES%22%2C%20%22NO%22%7D%20default%20button%20def_int%28auto_send%29%29%0D%09%09%09set%20add_label%20to%20button%20returned%20of%20%28display%20dialog%20%22Shall%20the%20script%20add%20a%20label%20to%20each%20file%20name%3F%22%20with%20title%20%22Add%20Labels%22%20buttons%20%7B%22YES%22%2C%20%22NO%22%7D%20default%20button%20def_int%28add_label%29%29%0D%09%09%09if%20add_label%20is%20%22YES%22%20then%20set%20a_label%20to%20text%20returned%20of%20%28display%20dialog%20%22Edit%20Label%3A%22%20default%20answer%20a_label%20buttons%20%7B%22OK%22%7D%20default%20button%201%29%0D%09%09%09set%20add_form%20to%20button%20returned%20of%20%28display%20dialog%20%22Shall%20the%20script%20add%20a%20form%20letter%20to%20each%20message%3F%22%20with%20title%20%22Add%20Form%20Letter%22%20buttons%20%7B%22YES%22%2C%20%22NO%22%7D%20default%20button%20def_int%28add_form%29%29%0D%09%09%09if%20add_form%20is%20%22YES%22%20then%20set%20form_letter%20to%20text%20returned%20of%20%28display%20dialog%20%22Edit%20your%20form%20letter.%20The%20placeholders%20%2ANAME%2A%20and%20%2APROJ%2A%20are%20automatically%20replaced%20with%20the%20appropriate%20values%20at%20run%20time.%22%20with%20title%20%22Edit%20Form%20Letter%22%20default%20answer%20form_letter%20buttons%20%7B%22OK%22%7D%20default%20button%201%29%0D%09%09%09set%20prompt_labels%20to%20%7B%22Recipient%20Address%22%2C%20%22File%20Label%22%2C%20%22Project%20Name%22%2C%20%22%22%7D%0D%09%09%09set%20my_prompt_settings%20to%20%7Bprompt_address%2C%20prompt_label%2C%20prompt_project%2C%20%22%22%7D%0D%09%09%09set%20my_prompts%20to%20%7B%7D%0D%09%09%09repeat%20with%20x%20from%201%20to%20the%20length%20of%20prompt_labels%0D%09%09%09%09if%20item%20x%20of%20my_prompt_settings%20is%20%22YES%22%20then%20set%20end%20of%20my_prompts%20to%20item%20x%20of%20prompt_labels%0D%09%09%09end%20repeat%0D%09%09%09set%20my_prompts%20to%20%28choose%20from%20list%20prompt_labels%20with%20prompt%20%22Select%20items%20to%20confirm%20at%20run%20time.%22%20%26%20return%20%26%20return%20%26%20%22Use%20the%20command%20key%20to%20select%20multiple%20items%22%20default%20items%20my_prompts%20with%20title%20%22Prompt%20Options%22%20with%20multiple%20selections%20allowed%20and%20empty%20selection%20allowed%29%20as%20list%0D%09%09%09set%20%7Bprompt_address%2C%20prompt_label%2C%20prompt_project%7D%20to%20%7B%22NO%22%2C%20%22NO%22%2C%20%22NO%22%7D%0D%09%09%09if%20%22Recipient%20Address%22%20is%20in%20my_prompts%20then%20set%20prompt_address%20to%20%22YES%22%0D%09%09%09if%20%22File%20Label%22%20is%20in%20my_prompts%20then%20set%20prompt_label%20to%20%22YES%22%0D%09%09%09if%20%22Project%20Name%22%20is%20in%20my_prompts%20then%20set%20prompt_project%20to%20%22YES%22%0D%09%09end%20if%0D%09%09if%20my_option%20is%20%22OK%22%20then%20exit%20repeat%0D%09end%20repeat%0Dend%20run%0Don%20def_int%28bool%29%0D%09if%20bool%20is%20%22YES%22%20then%20return%201%0D%09return%202%0Dend%20def_int%0Don%20open%20my_files%0D%09set%20%7BTID%2C%20text%20item%20delimiters%7D%20to%20%7Btext%20item%20delimiters%2C%20%22%22%7D%0D%09if%20prompt_address%20is%20%22YES%22%20then%20set%20an_address%20to%20text%20returned%20of%20%28display%20dialog%20%22Edit%20E-mail%20Recipient%3A%22%20default%20answer%20an_address%29%0D%09if%20prompt_label%20is%20%22YES%22%20then%0D%09%09set%20add_label%20to%20%22YES%22%0D%09%09set%20a_label%20to%20text%20returned%20of%20%28display%20dialog%20%22Enter%20a%20new%20label%2C%20or%20leave%20blank%20for%20no%20label.%22%20with%20title%20%22Edit%20Label%22%20default%20answer%20a_label%29%0D%09end%20if%0D%09if%20prompt_project%20is%20%22YES%22%20then%20set%20proj_name%20to%20text%20returned%20of%20%28display%20dialog%20%22Edit%20Project%20Name%3A%22%20default%20answer%20proj_name%29%0D%09set%20my_subject%20to%20%7B%7D%0D%09if%20hide_ext%20is%20%22YES%22%20then%0D%09%09tell%20application%20%22Finder%22%20to%20repeat%20with%20x%20in%20my_files%0D%09%09%09try%0D%09%09%09%09set%20AppleScript%27s%20text%20item%20delimiters%20to%20%28%22.%22%20%26%20%28name%20extension%20of%20contents%20of%20x%29%29%0D%09%09%09%09set%20my_subject%20to%20my_subject%20%26%20%28first%20text%20item%20of%20%28name%20of%20contents%20of%20x%20as%20Unicode%20text%29%29%0D%09%09%09end%20try%0D%09%09end%20repeat%0D%09else%0D%09%09tell%20application%20%22Finder%22%20to%20repeat%20with%20x%20in%20my_files%0D%09%09%09set%20my_subject%20to%20my_subject%20%26%20%28name%20of%20contents%20of%20x%29%0D%09%09end%20repeat%0D%09end%20if%0D%09set%20text%20item%20delimiters%20to%20%22%22%0D%09if%20add_label%20is%20%22YES%22%20then%0D%09%09repeat%20with%20x%20from%201%20to%20the%20length%20of%20my_subject%0D%09%09%09set%20item%20x%20of%20my_subject%20to%20%28item%20x%20of%20my_subject%20%26%20a_label%20as%20Unicode%20text%29%0D%09%09end%20repeat%0D%09end%20if%0D%09set%20text%20item%20delimiters%20to%20%22%2C%20%22%0D%09set%20my_subject%20to%20my_subject%20as%20Unicode%20text%0D%09set%20final_form%20to%20%22%22%0D%09if%20add_form%20is%20%22YES%22%20then%0D%09%09set%20text%20item%20delimiters%20to%20%22%2ANAME%2A%22%0D%09%09set%20final_form%20to%20form_letter%27s%20text%20items%0D%09%09set%20text%20item%20delimiters%20to%20a_name%0D%09%09set%20final_form%20to%20final_form%20as%20Unicode%20text%0D%09%09set%20text%20item%20delimiters%20to%20%22%2APROJ%2A%22%0D%09%09set%20final_form%20to%20final_form%27s%20text%20items%0D%09%09set%20text%20item%20delimiters%20to%20proj_name%0D%09%09set%20final_form%20to%20final_form%20as%20Unicode%20text%0D%09%09set%20text%20item%20delimiters%20to%20%22%22%0D%09end%20if%0D%09tell%20application%20%22Mail%22%0D%09%09activate%0D%09%09set%20my_message%20to%20make%20new%20outgoing%20message%20with%20properties%20%7Bsubject%3Amy_subject%2C%20content%3Afinal_form%20%26%20return%20%26%20return%7D%20--%20add%20code%3A/%20sender%3A%22foo%40bar.com%22%2C%20/%3Acode%20to%20this%20record%20to%20send%20from%20a%20particular%20account.%0D%09%09tell%20my_message%0D%09%09%09set%20visible%20to%20true%0D%09%09%09make%20new%20to%20recipient%20at%20end%20of%20to%20recipients%20with%20properties%20%7Baddress%3Aan_address%7D%0D%09%09%09repeat%20with%20x%20in%20my_files%0D%09%09%09%09tell%20content%20to%20make%20new%20attachment%20with%20properties%20%7Bfile%20name%3A%28contents%20of%20x%29%7D%20at%20after%20the%20last%20paragraph%0D%09%09%09end%20repeat%0D%09%09%09if%20auto_send%20is%20%22YES%22%20then%20send%0D%09%09end%20tell%0D%09end%20tell%0D%09set%20text%20item%20delimiters%20to%20TID%0Dend%20open%0D%28%2A%20written%20November%2024%2C%202005%20by%20Michael%20Henley%0Dmike.com%40mac.com%20%2A%29&quot;&gt;open this script in your editor&lt;/a&gt;&lt;pre style=&quot;font-family: &amp;#39;Monaco&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px&quot;&gt;property an_address : &quot;jdoe@apple.com&quot;&lt;br /&gt;property a_name : &quot;Jane Doe&quot;&lt;br /&gt;property proj_name : &quot;Generic Project&quot;&lt;br /&gt;property hide_ext : &quot;NO&quot;&lt;br /&gt;property auto_send : &quot;NO&quot;&lt;br /&gt;property add_label : &quot;NO&quot;&lt;br /&gt;property a_label : &quot; - Final&quot;&lt;br /&gt;property add_form : &quot;NO&quot;&lt;br /&gt;property prompt_address : &quot;NO&quot;&lt;br /&gt;property prompt_label : &quot;NO&quot;&lt;br /&gt;property prompt_project : &quot;NO&quot;&lt;br /&gt;property form_letter : &quot;Hello *NAME*,&lt;br /&gt;&lt;br /&gt;Attached are the files for \&quot;*PROJ*.\&quot;&lt;br /&gt;&lt;br /&gt;Thank you,&lt;br /&gt;My Name&lt;br /&gt;&quot;&lt;br /&gt;(* the preceding are merely default values, they&lt;br /&gt;do not need to be edited here, and will only&lt;br /&gt;reset when the script is recompiled *)&lt;br /&gt;on run&lt;br /&gt;	repeat&lt;br /&gt;		set {label_preview, form_preview} to {&quot;NO - Add Label&quot;, &quot;NO - Add Form Letter&quot;}&lt;br /&gt;		if add_label is &quot;YES&quot; then set label_preview to &quot;YES - Add Label &quot; &amp;amp; quoted form of a_label&lt;br /&gt;		if add_form is &quot;YES&quot; then set form_preview to &quot;YES - Add Form Letter:&quot; &amp;amp; return &amp;amp; return &amp;amp; form_letter&lt;br /&gt;		&lt;br /&gt;		display dialog &quot;Recipient: &quot; &amp;amp; a_name &amp;amp; space &amp;amp; (quoted form of an_address) &amp;amp; return &amp;amp; &quot;&lt;br /&gt;&quot; &amp;amp; hide_ext &amp;amp; &quot; - Hide File Extensions&lt;br /&gt;&quot; &amp;amp; auto_send &amp;amp; &quot; - Auto-Send&lt;br /&gt;&quot; &amp;amp; label_preview &amp;amp; return &amp;amp; form_preview &amp;amp; return &amp;amp; &quot;&lt;br /&gt;Always Prompt for:&amp;nbsp;&lt;br /&gt;&quot; &amp;amp; prompt_address &amp;amp; &quot; - Recipient&lt;br /&gt;&quot; &amp;amp; prompt_label &amp;amp; &quot; - Label&lt;br /&gt;&quot; &amp;amp; prompt_project &amp;amp; &quot; - Project&quot; with title &quot;Script Preferences&quot; buttons {&quot;Edit Recipient&quot;, &quot;Other Settings&quot;, &quot;OK&quot;} default button 3&lt;br /&gt;		copy button returned of result to my_option&lt;br /&gt;		if my_option is &quot;Edit Recipient&quot; then&lt;br /&gt;			set an_address to text returned of (display dialog &quot;Edit E-mail Recipient:&quot; default answer an_address)&lt;br /&gt;			display dialog &quot;Edit Recipient&apos;s Name:&quot; default answer a_name buttons {&quot;Other Settings&quot;, &quot;OK&quot;}&lt;br /&gt;			copy {text returned, button returned} of result to {a_name, my_option}&lt;br /&gt;		end if&lt;br /&gt;		if my_option is &quot;Other Settings&quot; then&lt;br /&gt;			set hide_ext to button returned of (display dialog &quot;Shall the script hide all file extensions?&quot; with title &quot;Hide File Extenstions&quot; buttons {&quot;YES&quot;, &quot;NO&quot;} default button def_int(hide_ext))&lt;br /&gt;			set auto_send to button returned of (display dialog &quot;Shall the script automatically send the message when it runs?&quot; with title &quot;Auto-Send&quot; buttons {&quot;YES&quot;, &quot;NO&quot;} default button def_int(auto_send))&lt;br /&gt;			set add_label to button returned of (display dialog &quot;Shall the script add a label to each file name?&quot; with title &quot;Add Labels&quot; buttons {&quot;YES&quot;, &quot;NO&quot;} default button def_int(add_label))&lt;br /&gt;			if add_label is &quot;YES&quot; then set a_label to text returned of (display dialog &quot;Edit Label:&quot; default answer a_label buttons {&quot;OK&quot;} default button 1)&lt;br /&gt;			set add_form to button returned of (display dialog &quot;Shall the script add a form letter to each message?&quot; with title &quot;Add Form Letter&quot; buttons {&quot;YES&quot;, &quot;NO&quot;} default button def_int(add_form))&lt;br /&gt;			if add_form is &quot;YES&quot; then set form_letter to text returned of (display dialog &quot;Edit your form letter. The placeholders *NAME* and *PROJ* are automatically replaced with the appropriate values at run time.&quot; with title &quot;Edit Form Letter&quot; default answer form_letter buttons {&quot;OK&quot;} default button 1)&lt;br /&gt;			set prompt_labels to {&quot;Recipient Address&quot;, &quot;File Label&quot;, &quot;Project Name&quot;, &quot;&quot;}&lt;br /&gt;			set my_prompt_settings to {prompt_address, prompt_label, prompt_project, &quot;&quot;}&lt;br /&gt;			set my_prompts to {}&lt;br /&gt;			repeat with x from 1 to the length of prompt_labels&lt;br /&gt;				if item x of my_prompt_settings is &quot;YES&quot; then set end of my_prompts to item x of prompt_labels&lt;br /&gt;			end repeat&lt;br /&gt;			set my_prompts to (choose from list prompt_labels with prompt &quot;Select items to confirm at run time.&quot; &amp;amp; return &amp;amp; return &amp;amp; &quot;Use the command key to select multiple items&quot; default items my_prompts with title &quot;Prompt Options&quot; with multiple selections allowed and empty selection allowed) as list&lt;br /&gt;			set {prompt_address, prompt_label, prompt_project} to {&quot;NO&quot;, &quot;NO&quot;, &quot;NO&quot;}&lt;br /&gt;			if &quot;Recipient Address&quot; is in my_prompts then set prompt_address to &quot;YES&quot;&lt;br /&gt;			if &quot;File Label&quot; is in my_prompts then set prompt_label to &quot;YES&quot;&lt;br /&gt;			if &quot;Project Name&quot; is in my_prompts then set prompt_project to &quot;YES&quot;&lt;br /&gt;		end if&lt;br /&gt;		if my_option is &quot;OK&quot; then exit repeat&lt;br /&gt;	end repeat&lt;br /&gt;end run&lt;br /&gt;on def_int(bool)&lt;br /&gt;	if bool is &quot;YES&quot; then return 1&lt;br /&gt;	return 2&lt;br /&gt;end def_int&lt;br /&gt;on open my_files&lt;br /&gt;	set {TID, text item delimiters} to {text item delimiters, &quot;&quot;}&lt;br /&gt;	if prompt_address is &quot;YES&quot; then set an_address to text returned of (display dialog &quot;Edit E-mail Recipient:&quot; default answer an_address)&lt;br /&gt;	if prompt_label is &quot;YES&quot; then&lt;br /&gt;		set add_label to &quot;YES&quot;&lt;br /&gt;		set a_label to text returned of (display dialog &quot;Enter a new label, or leave blank for no label.&quot; with title &quot;Edit Label&quot; default answer a_label)&lt;br /&gt;	end if&lt;br /&gt;	if prompt_project is &quot;YES&quot; then set proj_name to text returned of (display dialog &quot;Edit Project Name:&quot; default answer proj_name)&lt;br /&gt;	set my_subject to {}&lt;br /&gt;	if hide_ext is &quot;YES&quot; then&lt;br /&gt;		tell application &quot;Finder&quot; to repeat with x in my_files&lt;br /&gt;			try&lt;br /&gt;				set AppleScript&apos;s text item delimiters to (&quot;.&quot; &amp;amp; (name extension of contents of x))&lt;br /&gt;				set my_subject to my_subject &amp;amp; (first text item of (name of contents of x as Unicode text))&lt;br /&gt;			end try&lt;br /&gt;		end repeat&lt;br /&gt;	else&lt;br /&gt;		tell application &quot;Finder&quot; to repeat with x in my_files&lt;br /&gt;			set my_subject to my_subject &amp;amp; (name of contents of x)&lt;br /&gt;		end repeat&lt;br /&gt;	end if&lt;br /&gt;	set text item delimiters to &quot;&quot;&lt;br /&gt;	if add_label is &quot;YES&quot; then&lt;br /&gt;		repeat with x from 1 to the length of my_subject&lt;br /&gt;			set item x of my_subject to (item x of my_subject &amp;amp; a_label as Unicode text)&lt;br /&gt;		end repeat&lt;br /&gt;	end if&lt;br /&gt;	set text item delimiters to &quot;, &quot;&lt;br /&gt;	set my_subject to my_subject as Unicode text&lt;br /&gt;	set final_form to &quot;&quot;&lt;br /&gt;	if add_form is &quot;YES&quot; then&lt;br /&gt;		set text item delimiters to &quot;*NAME*&quot;&lt;br /&gt;		set final_form to form_letter&apos;s text items&lt;br /&gt;		set text item delimiters to a_name&lt;br /&gt;		set final_form to final_form as Unicode text&lt;br /&gt;		set text item delimiters to &quot;*PROJ*&quot;&lt;br /&gt;		set final_form to final_form&apos;s text items&lt;br /&gt;		set text item delimiters to proj_name&lt;br /&gt;		set final_form to final_form as Unicode text&lt;br /&gt;		set text item delimiters to &quot;&quot;&lt;br /&gt;	end if&lt;br /&gt;	tell application &quot;Mail&quot;&lt;br /&gt;		activate&lt;br /&gt;		set my_message to make new outgoing message with properties {subject:my_subject, content:final_form &amp;amp; return &amp;amp; return} -- add code:/ sender:&quot;foo@bar.com&quot;, /:code to this record to send from a particular account.&lt;br /&gt;		tell my_message&lt;br /&gt;			set visible to true&lt;br /&gt;			make new to recipient at end of to recipients with properties {address:an_address}&lt;br /&gt;			repeat with x in my_files&lt;br /&gt;				tell content to make new attachment with properties {file name:(contents of x)} at after the last paragraph&lt;br /&gt;			end repeat&lt;br /&gt;			if auto_send is &quot;YES&quot; then send&lt;br /&gt;		end tell&lt;br /&gt;	end tell&lt;br /&gt;	set text item delimiters to TID&lt;br /&gt;end open&lt;br /&gt;(* written November 24, 2005 by Michael Henley&lt;br /&gt;mike.com@mac.com *)&lt;/pre&gt;</description>
  <comments>http://automagical.livejournal.com/1862.html</comments>
  <category>mail</category>
  <category>droplet</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://automagical.livejournal.com/1742.html</guid>
  <pubDate>Thu, 17 Nov 2005 19:47:15 GMT</pubDate>
  <title>Assign unique filenames to screen captures</title>
  <link>http://automagical.livejournal.com/1742.html</link>
  <description>Re: &lt;a href=&quot;http://discussions.apple.com/thread.jspa?messageID=1174674&quot;&gt;How could I modify this script to make the name of each file unique?&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;                    There are many ways to do this.  For one, if you define a &apos;property&apos; instead of a &apos;global&apos; then the script will remember any variable you like for just about eternity.  Between runs, between boots, you name it.  The only thing that would reset the property to its default setting is re-compiling the script itself.&lt;br&gt;&lt;br&gt;But giving each file a unique name is more useful, and there are as many ways to do this as there are ways to slice and dice the results of AppleScript&apos;s &apos;current date&apos; command.&lt;br&gt;&lt;br&gt;Here is my suggestion, it outputs files that look like this:&lt;br&gt;&lt;br&gt;screen 17-Nov-2005 1.10.30 AM.pdf&lt;br&gt;screen 17-Nov-2005 1.10.40 AM.pdf&lt;br&gt;screen 17-Nov-2005 1.10.50 AM.pdf&lt;br&gt;screen 17-Nov-2005 1.11.00 AM.pdf&lt;br&gt;screen 17-Nov-2005 1.11.10 AM.pdf&lt;br&gt;&lt;br&gt;Note that I tweaked your script so that it takes screenshots precisely at each 10th second of each minute.  This was just an aesthetic consideration for me, feel free to omit it.&lt;br&gt;&lt;a name=&quot;cutid1&quot;&gt;&lt;/a&gt;&lt;br&gt;click here to &lt;a href=&quot;applescript://com.apple.scripteditor?action=new&amp;amp;script=property%20x%20%3A%200%0Dset%20x%20to%200%0D%0Dtell%20%28current%20date%29%27s%20time%20to%2010%20-%20it%20mod%2010%0Ddelay%20result%0D%0Don%20idle%0D%09do%20shell%20script%20%22screencapture%20-x%20%7E/snaps/%22%20%26%20%C2%AC%0D%09%09quoted%20form%20of%20%28%22screen%20%22%20%26%20get_time%28%29%20%26%20%22.pdf%22%29%0D%09set%20x%20to%20x%20%2B%201%0D%09if%20x%20%3D%205%20then%20quit%0D%09tell%20%28current%20date%29%27s%20time%20to%2010%20-%20it%20mod%2010%0Dend%20idle%0D%0Don%20get_time%28%29%0D%09set%20%7BTID%2C%20text%20item%20delimiters%7D%20to%20%7Btext%20item%20delimiters%2C%20%22%22%7D%0D%09tell%20%28current%20date%29%0D%09%09set%20am%20to%20%22AM%22%0D%09%09set%20d%20to%20%22.%22%0D%09%09set%20z%20to%20it%27s%20hours%0D%09%09if%20z%20%3E%2012%20then%0D%09%09%09set%20am%20to%20%22PM%22%0D%09%09%09set%20z%20to%20z%20-%2012%0D%09%09end%20if%0D%09%09set%20y%20to%20it%27s%20minutes%20as%20string%0D%09%09if%20length%20of%20y%20is%201%20then%20set%20y%20to%20%220%22%20%26%20y%0D%09%09set%20timestring%20to%20z%20%26%20d%20%26%20y%20%26%20d%20%26%20it%27s%20seconds%20%26%20space%20%26%20am%20as%20string%0D%09%09%28it%27s%20day%20as%20integer%29%20%26%20%22-%22%20%26%20characters%201%20thru%203%20of%20%28it%27s%20month%20as%20string%29%0D%09%09set%20timestamp%20to%20result%20%26%20%22-%22%20%26%20it%27s%20year%20%26%20space%20%26%20timestring%20as%20string%0D%09end%20tell%0D%09set%20text%20item%20delimiters%20to%20TID%0D%09return%20timestamp%0Dend%20get_time&quot;&gt;open this script in your editor&lt;/a&gt;&lt;pre style=&quot;font-family: &amp;#39;Monaco&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px&quot;&gt;property x : 0&lt;br /&gt;set x to 0&lt;br /&gt;&lt;br /&gt;tell (current date)&apos;s time to 10 - it mod 10&lt;br /&gt;delay result&lt;br /&gt;&lt;br /&gt;on idle&lt;br /&gt;	do shell script &quot;screencapture -x ~/snaps/&quot; &amp;#38; ¬&lt;br /&gt;		quoted form of (&quot;screen &quot; &amp;#38; get_time() &amp;#38; &quot;.pdf&quot;)&lt;br /&gt;	set x to x + 1&lt;br /&gt;	if x = 5 then quit&lt;br /&gt;	tell (current date)&apos;s time to 10 - it mod 10&lt;br /&gt;end idle&lt;br /&gt;&lt;br /&gt;on get_time()&lt;br /&gt;	set {TID, text item delimiters} to {text item delimiters, &quot;&quot;}&lt;br /&gt;	tell (current date)&lt;br /&gt;		set am to &quot;AM&quot;&lt;br /&gt;		set d to &quot;.&quot;&lt;br /&gt;		set z to it&apos;s hours&lt;br /&gt;		if z &amp;gt; 12 then&lt;br /&gt;			set am to &quot;PM&quot;&lt;br /&gt;			set z to z - 12&lt;br /&gt;		end if&lt;br /&gt;		set y to it&apos;s minutes as string&lt;br /&gt;		if length of y is 1 then set y to &quot;0&quot; &amp;#38; y&lt;br /&gt;		set timestring to z &amp;#38; d &amp;#38; y &amp;#38; d &amp;#38; it&apos;s seconds &amp;#38; space &amp;#38; am as string&lt;br /&gt;		(it&apos;s day as integer) &amp;#38; &quot;-&quot; &amp;#38; characters 1 thru 3 of (it&apos;s month as string)&lt;br /&gt;		set timestamp to result &amp;#38; &quot;-&quot; &amp;#38; it&apos;s year &amp;#38; space &amp;#38; timestring as string&lt;br /&gt;	end tell&lt;br /&gt;	set text item delimiters to TID&lt;br /&gt;	return timestamp&lt;br /&gt;end get_time&lt;/pre&gt;</description>
  <comments>http://automagical.livejournal.com/1742.html</comments>
  <category>screenshots</category>
  <category>tids</category>
  <category>shell</category>
  <category>date</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://automagical.livejournal.com/1531.html</guid>
  <pubDate>Sun, 11 Sep 2005 04:39:19 GMT</pubDate>
  <title>AppleScript calling LiveJournal</title>
  <link>http://automagical.livejournal.com/1531.html</link>
  <description>Here&apos;s a simple script I wrote that you can use to post directly to LiveJournal from AppleScript.  This is only a small example of how you can interact with LiveJournal using AppleScript.  For more information on their XML-RPC implementation and syntax, &lt;a href=&quot;http://www.livejournal.com/doc/server/ljp.csp.xml-rpc.protocol.html&quot;&gt;look here&lt;/a&gt;. Remember that AppleScript treats structs as {{|records|:within, |single|:parameters}}, and don&apos;t forget to |pipe| all your labels (which should match LJ&apos;s xml fields) to prevent scripting addition conflicts. &lt;a name=&quot;cutid1&quot;&gt;&lt;/a&gt;&lt;small&gt;&lt;pre&gt;-- the name of your livejournal account
set my_name to &quot;YOUR USERNAME&quot;

-- the subject line for you entry:
set my_topic to &quot;I&apos;m Awesome!&quot;

-- the body of your entry:
set my_post to &quot;I posted this directly from AppleScript using LiveJournal&apos;s XML-RPC API. Kickass.&quot;

-- password dialog (sent in the clear, see LJ docs for safer methods)
copy {text returned of (display dialog &quot;Enter password for &quot; &amp; quoted form of my_name with title ¬
	&quot;LiveJournal Post Event&quot; with icon stop default answer &quot;&quot; with hidden answer), &quot;clear&quot;} to ¬
	{my_pass, my_auth}

-- figure out the time and date of your post based on local system time
set post_time to time of (current date)
if post_time ≥ hours then
	copy {post_time div hours, post_time mod hours} to ¬
		{my_hour, minute_x}
	copy {minute_x div minutes, minute_x mod minutes} to ¬
		{my_minute, my_second}
else if post_time ≥ minutes then
	copy {0, post_time div minutes, post_time mod minutes} to ¬
		{my_hour, my_minute, my_second}
else
	copy {0, 0, post_time} to {my_hour, my_minute, my_second}
end if
current date
copy {year of result, month of result as integer, day of result} to {my_year, my_month, my_day}

-- the actual post event
tell application &quot;http://www.livejournal.com/interface/xmlrpc&quot; to call xmlrpc ¬
	{method name:&quot;LJ.XMLRPC.postevent&quot;, parameters:¬
		{{username:my_name, auth_method:my_auth, |password|:my_pass, |event|:¬
			my_post, lineendings:&quot;mac&quot;, subject:my_topic, security:&quot;&quot;, allowmask:0, |year|:¬
			my_year, mon:my_month, |day|:¬
			my_day, hour:my_hour, min:my_minute}}}

-- open the entry in your default browser
open location (|url| of result)
&lt;/pre&gt;&lt;/small&gt;&lt;br /&gt;&lt;a href=&quot;http://bbs.applescript.net/viewtopic.php?pid=45542&quot;&gt;x-posted&lt;/a&gt;</description>
  <comments>http://automagical.livejournal.com/1531.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://automagical.livejournal.com/1030.html</guid>
  <pubDate>Mon, 18 Jul 2005 02:08:17 GMT</pubDate>
  <title>Upload ScreenCap 0.2</title>
  <link>http://automagical.livejournal.com/1030.html</link>
  <description>This script will take a screenshot at regular &lt;br /&gt;intervals, resize it, and then upload it to a web &lt;br /&gt;server.&lt;a name=&quot;cutid1&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;small&gt;&lt;pre&gt;
(*
Upload ScreenCap
Written by Michael Henley (mike.com@mac.com)
version 0.2 (17Jul05)

This script will take a screenshot at regular 
intervals, resize it, and then upload it to a web 
server.

To use the script, simply copy this code to Script 
Editor (in your applications/AppleScript folder) 
and save it as an Application with the &quot;stay open&quot; 
option selected.

You should also edit the values set in the &quot;on 
run&quot; handler so that the script knows where to 
upload your file.
*)

global interval, capSize, capTitle, uploadLoc

on run
	set interval to 5 * 60 -- update frequency (5min x 60sec = 300sec)
	set capSize to 800 -- the max re-size value in pixels
	set capTitle to &quot;screencap.jpg&quot; -- the name of the image file
	set uploadLoc to &quot;http://USER:PASS@idisk.mac.com/mike.com/Sites/&quot; (* the URL to your server
	you can protect your user/pass by saving this script using
	the &quot;Run Only&quot; option (uneditable) or you can omit it and
	add &quot;with authentication&quot; where indicated in the script. *)
end run

on idle
	do shell script &quot;screencapture &quot; &amp; quoted form of (&quot;/&quot; &amp; capTitle)
	tell application &quot;Finder&quot; to set screenCap to ((startup disk as string) &amp; capTitle)
	tell application &quot;Image Events&quot;
		set theImage to open file screenCap as alias
		scale theImage to size capSize
		save theImage as JPEG
		-- acceptable format names: BMP JPEG JPEG2 PICT PNG PSD QuickTime Image TIFF
		close theImage
	end tell
	tell application &quot;URL Access Scripting&quot; to upload screenCap to uploadLoc -- with authentication
	return interval
end idle
&lt;/pre&gt;&lt;/small&gt;</description>
  <comments>http://automagical.livejournal.com/1030.html</comments>
  <category>screenshots</category>
  <category>uploading</category>
  <category>image events</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://automagical.livejournal.com/780.html</guid>
  <pubDate>Mon, 18 Jul 2005 02:04:48 GMT</pubDate>
  <title>Safe Delete 0.2</title>
  <link>http://automagical.livejournal.com/780.html</link>
  <description>This script can be used as a &quot;safe&quot; alternative &lt;br /&gt;to the standard iTunes delete command.  To use &lt;br /&gt;it, simply select one or more tracks in your &lt;br /&gt;iTunes library that you&apos;d like to delete, and &lt;br /&gt;then run the script.  The script will attempt to &lt;br /&gt;delete those files after checking to see if they &lt;br /&gt;appear in any of your user playlists. If a &lt;br /&gt;particular track appears in one or more &lt;br /&gt;playlists, the script displays a dialog box that &lt;br /&gt;asks if you&apos;re certain you want to delete that &lt;br /&gt;particular track.  The dialog box will tell you &lt;br /&gt;the name of the track, and the name of each &lt;br /&gt;playlist it appears in, excluding smart &lt;br /&gt;playlists and party shuffle.&lt;a name=&quot;cutid1&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;small&gt;&lt;pre&gt;(*
Safe Delete version 0.2a

This script can be used as a &quot;safe&quot; alternative 
to the standard iTunes delete command.  To use 
it, simply select one or more tracks in your 
iTunes library that you&apos;d like to delete, and 
then run the script.  The script will attempt to 
delete those files after checking to see if they 
appear in any of your user playlists. If a 
particular track appears in one or more 
playlists, the script displays a dialog box that 
asks if you&apos;re certain you want to delete that 
particular track.  The dialog box will tell you 
the name of the track, and the name of each 
playlist it appears in, excluding smart 
playlists and party shuffle.

The script is still being tested, therefore it 
is defaulted to a &quot;test mode&quot; that can&apos;t delete 
any files in your library.  If you want to make 
the script work normally, you must replace the 
line &quot;set testMode to true&quot; with &quot;set testMode 
to false&quot;

July 13, 2005
Written by Michael Henley (mike.com@mac.com)

File History:
13Jul05
- streamlined comparison routine to improve speed.
- now pre-loads all playlist data into a variable.
- now includes Purchased Music, if available.
- fixed a delete track bug
- fixed a bug where blank playlists could
  cause the script to malfunction.
*)
tell application &quot;iTunes&quot;
        set everyList to name of user playlists whose smart is false
        set selectedIDs to database ID of selection
        set selectedTitles to name of selection
        set everyListName to {}
        set everyListID to {}
        repeat with z from 2 to (count everyList) -- skip Party Shuffle
                set listName to item z of everyList as string
                set everyListName to everyListName &amp; listName as list
                try
                        set everyListID to everyListID &amp; {database ID of tracks of playlist listName} as list
                on error
                        set everyListID to everyListID &amp; {&quot;&quot; as list} as list
                end try
        end repeat
        repeat with x from 1 to (count selectedIDs)
                set anID to item x of selectedIDs
                set trackCheck to (item x of selectedTitles as string)
                set checkFlag to false
                set listCheck to &quot;&quot;
                repeat with y from 1 to (count everyListID)
                        set anListID to item y of everyListID
                        if anListID contains anID then
                                set listName to item y of everyListName as string
                                set checkFlag to true
                                set listCheck to listCheck &amp; return &amp; listName
                        end if
                end repeat
                if checkFlag then
                        display dialog &quot;The track \&quot;&quot; &amp; trackCheck &amp; &quot;\&quot;&quot; &amp; return &amp; &quot;is in the following playlists:&quot; &amp; return ¬
                                &amp; listCheck &amp; return &amp; return &amp; &quot;Do you want to delete it anyway?&quot; buttons {&quot;yes&quot;, &quot;no&quot;} default button 2
                        if the button returned of the result is &quot;yes&quot; then my deleteTrack(trackCheck)
                else
                        my deleteTrack(trackCheck)
                end if
        end repeat
end tell
on deleteTrack(trackCheck)
        set testMode to true -- change this to false if you want the script to work normally.
        tell application &quot;iTunes&quot;
                if testMode then
                        display dialog &quot;I did not delete the track \&quot;&quot; &amp; trackCheck &amp; &quot;\&quot;&quot; &amp; return &amp; &quot;because I am in test mode.&quot;
                else
                        set trackPath to location of track trackCheck of library playlist 1
                        delete track trackCheck of library playlist 1
                        tell application &quot;Finder&quot; to move trackPath to trash
                end if
        end tell
end deleteTrack
&lt;/pre&gt;&lt;/small&gt;</description>
  <comments>http://automagical.livejournal.com/780.html</comments>
  <category>database</category>
  <category>itunes</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://automagical.livejournal.com/527.html</guid>
  <pubDate>Sun, 03 Jul 2005 17:34:25 GMT</pubDate>
  <title>HyperSafari 1.0</title>
  <link>http://automagical.livejournal.com/527.html</link>
  <description>&lt;br&gt;&lt;br&gt;
HyperSafari is a very interesting little script that employs a lot of exotic custom handlers I&apos;ve been fine-tuning over the past few days.  Whereas it is most useful to me in its current form, I think most people might find parts of its code - some of which haven&apos;t been seen anywhere in a script before - inspiring. 
&lt;br&gt;&lt;br&gt;
Writing it for display on this blog greatly improved its efficiency and general orderliness. In particular I figured out some clever ways of dealing with uncertain window states in applications targeted by a GUI routine. 
&lt;br&gt;&lt;br&gt;
&lt;a name=&quot;cutid1&quot;&gt;&lt;/a&gt;
&lt;pre&gt;
(* 

HyperSafari 1.0
---------------
Written by Michael Henley (mike.com@mac.com)
July 3, 2005

HyperSafari is basically a digestive aid for the Internet.  It is a 
kitchen-sink script that handles a variety of meddlesome and repetitive 
tasks such as:

- quoting pages with full references
- filing downloaded images with relevant meta-data
- viewing hidden meta-tags
- stimulating the usage of a personal wiki
- harnessing the power of Folksonomy

There are a few ways to use this script, the preferred way (default) 
requires $70 worth of software. I have included, however, optional code 
that will make the script work without some or all of these apps. Keep 
reading for a discussion of the benefits of the various apps, and what to 
do if you don&apos;t have them.

The script is designed so that it can constantly &quot;monitor&quot; the activity in 
Safari. Unfortunately Safari can&apos;t be taught to notify the script of its 
activities without help from PreFab&apos;s $35 UI Actions.
http://prefab.com/uiactions/

If you have UI Actions, great! Simply set this script to fire whenever 
Safari posts the notification &quot;AXValueChanged&quot; and you&apos;re done! If you 
don&apos;t have UI Actions, you will need to delete the line labeled &quot;Step 1&quot; 
in the code.

The real power of this script shines when used in conjunction with the 
full version of Flying Meat&apos;s $25 VoodooPad. VoodooPad will automatically 
highlight keywords in the data it receives, and allow you to populate 
those keywords (or create new keywords) with the data you&apos;ve collected, 
along with any notes you enter manually.
http://flyingmeat.com/voodoopad/

If you don&apos;t want to buy the full version of VoodooPad, consider 
downloading their free version, VoodooPad Lite.  If you select this option 
you will need to delete the handler labeled &quot;Step 2&quot; in the code, and 
activate the handler labeled &quot;Step 3&quot;

If you&apos;d rather not be bothered with VoodooPad at all, I&apos;ve even included 
a handler for TextEdit.  To use this option, follow steps 2 and 4.

Finally, the activity of the UI action is most useful if you can keep the 
destination app&apos;s main window hovering above all other windows on your 
screen using Unsanity&apos;s $10 WindowShadeX.
http://www.unsanity.com/haxies/wsx/  

If you don&apos;t have WindowShadeX, however, no special modifications are 
necessary. The script will attempt to raise the destination window above 
other background windows without activating it, which is just one step 
below actual hovering.

As an added bonus, I&apos;ve thrown in a handler that gathers information about 
an individual image that has been loaded in a separate tab or window of 
Safari. It gives you the option to save the image to your hard drive in a 
keyword folder, and then writes links to its local &amp; remote files, its 
dimensions, title, even the website you got it from!

If you don&apos;t want to save a particular image, simply click &quot;cancel&quot; when 
the related dialog pops up.  If you don&apos;t want the image handler at all, 
follow Step 5, being sure to only cut out the marked code, leaving the 
saveimage() wrappers intact. (this is to prevent an annoying bug that 
occurs in Safari when JavaScript is accidentally run on an image file)

DISCLAIMERS: You assume all risks for your usage and/or modification of 
this code!

*)

ui(false)

property windowLog : &quot;&quot;
global vpDoc, vpPage, targetWindow, windowTest

set vpPage to &quot;launchpad&quot; -- REQUIRED. A blank page (or Text Edit document) to use for auto-updates.
set vpDoc to &quot;mikipiki.vdoc&quot; -- Required for VP. A VoodooPad document to use.
set hfsPath to &quot;hd1:tank:&quot; -- Optional. The folder where Images will be filed by keyword
set posixPath to &quot;/tank/&quot; -- Optional. Same location as hfsPath, used for the save image dialog and URI links

testWindow(hfsPath, posixPath)

on ui(state)
	-- Step 1: If you&apos;re not using UI Actions, remove the following line:
	tell application &quot;UI Actions&quot; to set enabled of UI action &quot;Safari-AXValueChanged&quot; to state
end ui

-- Step 2a: Cut out the following block of code if you are going to exercise either step 3 or step 4.
on launchpad(thetext)
	set theDate to (day of (current date) as string) &amp; (characters 1 thru 3 of (month of ¬
		(current date) as string)) &amp; (characters 3 thru 4 of (year of (current date) as string))
	set thetext to theDate &amp; return &amp; thetext
	tell application &quot;System Events&quot; to tell process &quot;VoodooPad&quot;
		set vpWindow to &quot;&quot;
		set theWindows to (name of every window as list)
		repeat with x in theWindows
			if x starts with vpDoc then set vpWindow to x as text
		end repeat
		if vpWindow is &quot;&quot; then display dialog &quot;The document &quot; &amp; vpDoc &amp; &quot; was not found. Make sure that it&apos;s open and that the title matches its script variable.&quot; buttons {&quot;Cancel&quot;} default button 1
		tell window vpWindow to perform action &quot;AXRaise&quot;
		if vpWindow does not end with vpPage then tell application &quot;VoodooPad&quot; to tell document ¬
			vpDoc to open page with title vpPage
		set value of text area 1 of scroll area 1 of window targetWindow to thetext
	end tell
	set the clipboard to thetext
end launchpad
-- Step 2b: Cut out the preceeding block of code if using an alternate handler.

(* Step 3a: Delete this line to use the VoodooPad Lite handler.

on launchpad(thetext)
	set theDate to (day of (current date) as string) &amp; (characters 1 thru 3 of (month of ¬
		(current date) as string)) &amp; (characters 3 thru 4 of (year of (current date) as string))
	set thetext to theDate &amp; return &amp; thetext
	tell application &quot;System Events&quot; to tell process &quot;VoodooPad Lite&quot;
		set vpWindow to &quot;&quot;
		set theWindows to (name of every window as list)
		repeat with x in theWindows
			if x starts with vpDoc then set vpWindow to x as text
		end repeat
		if vpWindow is &quot;&quot; then display dialog &quot;The document &quot; &amp; vpDoc &amp; ¬
			&quot; was not found. Make sure that it&apos;s open and that the title matches its script variable.&quot; buttons {&quot;Cancel&quot;} default button 1
		tell window vpWindow to perform action &quot;AXRaise&quot;
		if vpWindow does not end with vpPage then
			tell application &quot;VoodooPad Lite&quot; to activate
			keystroke &quot;o&quot; using {shift down, command down}
			keystroke &quot;o&quot; using {shift down, command down}
			tell sheet 1 of window 1
				set value of combo box 1 to vpPage
				click button &quot;Open&quot;
			end tell
			tell application &quot;Safari&quot; to activate
		end if
		set value of text area 1 of scroll area 1 of window targetWindow to thetext
	end tell
end launchpad

Step 3b: Delete this line to use the VoodooPad Lite handler.  *)

(* Step 4a: Delete this line to use the TextEdit handler.

on launchpad(thetext)
	set theDate to (day of (current date) as string) &amp; (characters 1 thru 3 of (month of ¬
		(current date) as string)) &amp; (characters 3 thru 4 of (year of (current date) as string))
	set thetext to theDate &amp; return &amp; thetext
	tell application &quot;System Events&quot; to tell process &quot;TextEdit&quot;
		set textWindow to &quot;&quot;
		set theWindows to (name of every window as list)
		repeat with x in theWindows
			if x starts with vpPage then set textWindow to x as text
		end repeat
		if textWindow is &quot;&quot; then ¬
			display dialog &quot;To use this script, you must first open a TextEdit document (txt, rtf, etc) named \&quot;&quot; &amp; ¬
				vpPage &amp; &quot;\&quot;&quot; buttons {&quot;Cancel&quot;} default button 1
		tell window textWindow to perform action &quot;AXRaise&quot;
	end tell
	tell application &quot;TextEdit&quot; to set text of document textWindow to thetext
end launchpad

Step 4b: Delete this line to use the TextEdit handler. *)

on saveimage(hfsPath, posixPath)
	
	-- Step 5a cut out this block of code if you don&apos;t want automated image filing
	display dialog &quot;Enter a Keyword:&quot; default answer &quot;&quot; buttons {&quot;Cancel&quot;, &quot;OK&quot;} default button 2
	set the folderName to the text returned of the result
	tell application &quot;Finder&quot; to if (exists of folder (hfsPath &amp; folderName)) is false then ¬
		make new folder at hfsPath with properties {name:folderName}
	set posixPath to posixPath &amp; folderName
	tell application &quot;Safari&quot; to activate
	tell application &quot;System Events&quot; to tell process &quot;Safari&quot;
		click menu item &quot;Save As…&quot; of menu 1 of menu bar item &quot;File&quot; of menu bar 1
		keystroke &quot;g&quot; using {shift down, command down}
		repeat until (window &quot;Go to Folder&quot; exists)
			delay 0.5
		end repeat
		tell window &quot;Go To Folder&quot;
			set value of text field 1 to posixPath
			click button &quot;Go&quot;
		end tell
		tell sheet 1 of window 1
			set fileName to value of text field 1
			click button 1
		end tell
	end tell
	set vpPath to &quot;file://localhost&quot; &amp; posixPath &amp; &quot;/&quot; &amp; fileName
	tell application &quot;Safari&quot;
		set thetext to (name of window 1 as text) &amp; return &amp; ¬
			(URL of document of window 1 as text) &amp; return &amp; vpPath &amp; return &amp; folderName &amp; return
		tell application &quot;System Events&quot; to keystroke &quot;w&quot; using command down
		set thetext to thetext &amp; &quot;Source: &quot; &amp; (name of window 1 as text) &amp; return &amp; (URL of document of window 1 as text) &amp; return
	end tell
	launchpad(thetext)
	--Step 5b cut out the preceeding block of code if you don&apos;t want automated image filing
	
end saveimage

on testWindow(hfsPath, posixPath)
	set targetWindow to vpDoc &amp; &quot;:&quot; &amp; vpPage
	if page_loaded(20) is false then error -128
	if windowLog is &quot;&quot; then set windowLog to windowTest
	if windowTest is not windowLog then
		set windowLog to windowTest
		if windowTest ends with &quot;pixels&quot; then
			saveimage(hfsPath, posixPath)
		else if windowTest begins with &quot;Untitled&quot; then
			error number -128
		else
			safari()
		end if
	else
		ui(true)
	end if
	delay 1
	ui(true)
end testWindow

on safari()
	tell application &quot;Safari&quot;
		repeat with x from 0 to 5 by 1
			set theName to do JavaScript &quot;document.getElementsByTagName(\&quot;meta\&quot;).item(&quot; &amp; x &amp; &quot;).name&quot; in document 1
			if theName is &quot;keywords&quot; then exit repeat
		end repeat
		set theKeywords to do JavaScript &quot;document.getElementsByTagName(\&quot;meta\&quot;).item(&quot; &amp; x &amp; &quot;).content&quot; in document 1
		set thetext to (do JavaScript &quot;document.title&quot; in document 1) &amp; ¬
			return &amp; (do JavaScript &quot;document.URL&quot; in document 1) &amp; return &amp; theKeywords
	end tell
	launchpad(thetext)
end safari

on page_loaded(timeout_value)
	repeat with i from 1 to the timeout_value
		tell application &quot;Safari&quot;
			set windowTest to (name of window 1 as text)
			if windowTest does not start with &quot;Loading&quot; then
				return true
			else if i is the timeout_value then
				return false
			else
				delay 1
			end if
		end tell
	end repeat
	return false
end page_loaded
&lt;/pre&gt;
</description>
  <comments>http://automagical.livejournal.com/527.html</comments>
  <category>uiactions</category>
  <category>voodoopad</category>
  <category>safari</category>
  <lj:music>Elliott Smith - 2:45 Am</lj:music>
  <media:title type="plain">Elliott Smith - 2:45 Am</media:title>
  <lj:mood>pretty good</lj:mood>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://automagical.livejournal.com/278.html</guid>
  <pubDate>Sat, 02 Jul 2005 08:27:05 GMT</pubDate>
  <title>Download Files Here</title>
  <link>http://automagical.livejournal.com/278.html</link>
  <description>I&apos;m extremely pleased to report my first-ever submission to &lt;a href=&quot;http://scriptbuilders.net/files/downloadfileshere1.0.html&quot;&gt;ScriptBuilders.net&lt;/a&gt;!  After getting some great feedback on their message boards, I was asked by the the site admin to bundle it up and smack a version number on it.  It also happens to be a &lt;a href=&quot;http://scriptbuilders.net/files/downloadfileshere1.0.html&quot;&gt;pretty useful script&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a name=&quot;cutid1&quot;&gt;&lt;/a&gt;&lt;img src=&quot;http://homepage.mac.com/mike.com/.Pictures/automagical.jpg&quot;&gt;</description>
  <comments>http://automagical.livejournal.com/278.html</comments>
  <category>finder</category>
  <category>safari</category>
  <category>scriptbuilders</category>
  <lj:music>Beck - Get Real Paid</lj:music>
  <media:title type="plain">Beck - Get Real Paid</media:title>
  <lj:mood>pleased</lj:mood>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
</channel>
</rss>
