<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mac Tricks And Tips &#187; Apple Script</title>
	<atom:link href="http://www.mactricksandtips.com/category/apple-script/feed" rel="self" type="application/rss+xml" />
	<link>http://www.mactricksandtips.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Fri, 03 Feb 2012 15:10:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Use iTunes as an Alarm Clock</title>
		<link>http://www.mactricksandtips.com/2008/09/use-itunes-as-an-alarm-clock.html</link>
		<comments>http://www.mactricksandtips.com/2008/09/use-itunes-as-an-alarm-clock.html#comments</comments>
		<pubDate>Tue, 16 Sep 2008 18:30:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apple Script]]></category>
		<category><![CDATA[Applescript]]></category>
		<category><![CDATA[iTunes]]></category>

		<guid isPermaLink="false">http://www.mactricksandtips.com/?p=994</guid>
		<description><![CDATA[Earlier today I mentioned about . Awaken is a small application that you can use to set iTunes to go off at a particular time. This means that you can use it as an alarm clock. Although Awaken is a good application the main function, or setting aniTunes alarm, can be done free with a little bit of scripting and know how. This post will show you the basics. You can then take it further as you see fit.<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2008/09/use-itunes-as-an-alarm-clock.html">Use iTunes as an Alarm Clock</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2008/09/awaken-alarm-clock-macpromo.html' rel='bookmark' title='Permanent Link: Awaken &#8211; Alarm Clock &#8211; MacPromo'>Awaken &#8211; Alarm Clock &#8211; MacPromo</a></li>
<li><a href='http://www.mactricksandtips.com/2008/06/itunes-to-twitter-applescript.html' rel='bookmark' title='Permanent Link: iTunes To Twitter AppleScript'>iTunes To Twitter AppleScript</a></li>
<li><a href='http://www.mactricksandtips.com/2010/01/maximise-itunes-the-little-green-button.html' rel='bookmark' title='Permanent Link: Maximise iTunes (The Little Green Button)'>Maximise iTunes (The Little Green Button)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hey</p>
<p>Earlier today I mentioned about . Awaken is a small application that you can use to set iTunes to go off at a particular time. This means that you can use it as an alarm clock. Although Awaken is a good application the main function, or setting an iTunes alarm, can be done free with a little bit of scripting and know how. This post will show you the basics. You can then take it further as you see fit.</p>
<p>There are two ways of doing this in my opinion. Using Applescript and iCal or Applescript and cron. The first is very easy to set up, but you need to use iCal. If, like me, you have a full calendar, adding in another event will just fill up a bucket that is overflowing. The second option is a simpler option once you have set up. You don&#8217;t need to use iCal, just a link to a script. For the purpose of this post I am going to show you both.</p>
<p>The first step is to make your AppleScript. You can take this as far as you want. I have included a couple of features to make it more fun. As always I will explain what each line means and why it is included. First open up the Apple Script editor under Applications &gt; AppleScript &gt;Script Editor. Then paste into the window the following:</p>
<p><code>tell application "iTunes"<br />
launch<br />
stop<br />
set the_playlist to user playlist 1<br />
set sound volume to 100<br />
repeat 2 times<br />
set shuffle of the_playlist to false<br />
set shuffle of the_playlist to true<br />
end repeat<br />
play the_playlist<br />
tell application "System Events"<br />
tell application "iTunes" to activate<br />
key code 17 using command down<br />
key code 3 using command down<br />
end tell<br />
end tell</code></p>
<p>It looks very boring. I haven&#8217;t got syntax highlighting installed. But it does a couple of unique things.</p>
<p><code>tell application "iTunes"<br />
launch<br />
stop</code></p>
<p>This bit of code opens iTunes. The stop part is included because I was getting a couple of problems with running a playlist straight away.</p>
<p><code>set the_playlist to user playlist 1<br />
set sound volume to 100</code></p>
<p>This sets the playlist to be played as the Library. You can insert any name you want here if you want to play a different playlist. Make sure you include the name of the playlist in double quotes (&#8221; &#8220;). The second half sets the volume to maximum. As a side not if you do want to use this script make sure you have your computer volume on. It saves a lot of debugging problems.</p>
<p><code>repeat 2 times<br />
set shuffle of the_playlist to false<br />
set shuffle of the_playlist to true<br />
end repeat</code></p>
<p>This section just shuffles up the playlist twice. You can change the shuffle number to anything you want. From what I have read it is the same as pressing option click on the shuffle button.</p>
<p><code>play the_playlist</code></p>
<p>This is a major point in the code. It plays the playlist.</p>
<p><code>tell application "System Events"<br />
tell application "iTunes" to activate<br />
key code 17 using command down<br />
key code 3 using command down<br />
end tell<br />
end tell</code></p>
<p>Awaken had a funky screen overlay that enabled you to view the current track that is playing. I tried to do this with Front Row. Since I don&#8217;t have my iTunes library on my computer it wouldn&#8217;t find the tracks so I couldn&#8217;t run any AppleScript. As a compromise the script runs the iTunes visualizer. The keycode numbers were found using <a href="http://softwares.bajram.com/utilities/#Full_Key_Codes">Full Key Codes</a>. If you haven&#8217;t upgraded to iTunes 8 do it just for the funky new visualizer.</p>
<p>Once as you have pasted the script and ran it check to make sure it works, we can now add it to iCal. iCal need the script to be saved as a .scpt. In the Apple Script Editor save the file out, you don&#8217;t need to change anything settings wise. Then open iCal insert a new event at the time you want your computer to start playing music .  Set the Alarm to &#8220;Run Script&#8221; and find the script using the pop up.</p>
<p><a href="http://www.mactricksandtips.com/wp-content/uploads/2008/09/itunes-alarm-wakeup.png"><img class="aligncenter size-thumbnail wp-image-995" title="itunes-alarm-wakeup" src="http://www.mactricksandtips.com/wp-content/uploads/2008/09/itunes-alarm-wakeup-97x150.png" alt="" width="97" height="150" /></a></p>
<p>I said at the beginning of this post that you can do this with cron. It just as simple. Instead of saving the Apple Script as a script, save it out as an application. Then open Terminal and type the following.</p>
<p><code>crontab -a</code></p>
<p>Press the &#8220;a&#8221; key. Then add this on a new line if necesary.</p>
<p><code>30 7 * * * /Path/To/Script/scripname.app</code></p>
<p>Then press escape and type without quote &#8220;:wq!&#8221; it should then work at  you stated time. From the example above the Apple Script will run at 7:30am every day. You can customize this as much as you want. For more information refer to a quick Google Search on crontab.</p>
<h3>Conclusion</h3>
<p>Hopefully you can follow what I have written and you have successfully made your own iTunes alarm. Granted it is not as cool as Awaken but it is free. In my opinion it does the job just as well.</p>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2008/09/use-itunes-as-an-alarm-clock.html">Use iTunes as an Alarm Clock</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2008/09/awaken-alarm-clock-macpromo.html' rel='bookmark' title='Permanent Link: Awaken &#8211; Alarm Clock &#8211; MacPromo'>Awaken &#8211; Alarm Clock &#8211; MacPromo</a></li>
<li><a href='http://www.mactricksandtips.com/2008/06/itunes-to-twitter-applescript.html' rel='bookmark' title='Permanent Link: iTunes To Twitter AppleScript'>iTunes To Twitter AppleScript</a></li>
<li><a href='http://www.mactricksandtips.com/2010/01/maximise-itunes-the-little-green-button.html' rel='bookmark' title='Permanent Link: Maximise iTunes (The Little Green Button)'>Maximise iTunes (The Little Green Button)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Close All But The Current Finder Window</title>
		<link>http://www.mactricksandtips.com/2008/08/close-all-but-the-current-finder-window.html</link>
		<comments>http://www.mactricksandtips.com/2008/08/close-all-but-the-current-finder-window.html#comments</comments>
		<pubDate>Thu, 28 Aug 2008 19:36:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apple Script]]></category>
		<category><![CDATA[Applescript]]></category>
		<category><![CDATA[Finder]]></category>

		<guid isPermaLink="false">http://www.mactricksandtips.com/?p=877</guid>
		<description><![CDATA[If you Finder extensively to move around windows and files you will probably end up with a lot of Finder windows open. I like things neatly organised. The problem with this is that you can end up with a lot of screen clutter. With the help of the Internet I have come up with a quickApplescript that you can use to close every window but the one you are using. Its really simple to make and run.<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2008/08/close-all-but-the-current-finder-window.html">Close All But The Current Finder Window</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2010/08/open-your-current-terminal-directory-in-finder.html' rel='bookmark' title='Permanent Link: Open Your Current Terminal Directory In Finder'>Open Your Current Terminal Directory In Finder</a></li>
<li><a href='http://www.mactricksandtips.com/2009/04/close-apps-after-a-period-of-time.html' rel='bookmark' title='Permanent Link: Close Apps After A Period Of Time'>Close Apps After A Period Of Time</a></li>
<li><a href='http://www.mactricksandtips.com/2009/06/quickly-close-terminal-windows.html' rel='bookmark' title='Permanent Link: Quickly Close Terminal Windows'>Quickly Close Terminal Windows</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hey</p>
<p>If you Finder extensively to move around windows and files you will probably end up with a lot of Finder windows open. I like things neatly organised. The problem with this is that you can end up with a lot of screen clutter. With the help of the Internet I have come up with a quick Applescript that you can use to close every window but the one you are using. Its really simple to make and run.</p>
<p>First open up the Apple script editor in Applications and type or copy and paste the following code:</p>
<p><code>tell application "Finder"<br />
repeat while window 2 exists<br />
close window 2<br />
end repeat<br />
end tell</code></p>
<p>Hit the compile button. Then go to File &gt; Save As and set the File Format to Application. At the same time check the Run Only option and uncheck Startup Screen. Save this into a suitable place on your hard drive.</p>
<p>Open up a Finder window and drag your script into the sidebar or any other suitable location.</p>
<p><a href="http://www.mactricksandtips.com/wp-content/uploads/2008/08/finder-screen-shot.png"><img class="aligncenter size-medium wp-image-878" title="finder-screen-shot" src="http://www.mactricksandtips.com/wp-content/uploads/2008/08/finder-screen-shot.png" alt="" width="296" height="210" /></a></p>
<p>Then, to test, open up a couple of Finder windows. Hit that button and watch them close. The script will run where it will close every Finder window but the one you are using. Neat.</p>
<p>A quick Applescript tip that has saved me a lot of time. Also you can press Command + Option + W to close every window. You can also use the Command + Option key command while pressing the buttons in the top left of any window.</p>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2008/08/close-all-but-the-current-finder-window.html">Close All But The Current Finder Window</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2010/08/open-your-current-terminal-directory-in-finder.html' rel='bookmark' title='Permanent Link: Open Your Current Terminal Directory In Finder'>Open Your Current Terminal Directory In Finder</a></li>
<li><a href='http://www.mactricksandtips.com/2009/04/close-apps-after-a-period-of-time.html' rel='bookmark' title='Permanent Link: Close Apps After A Period Of Time'>Close Apps After A Period Of Time</a></li>
<li><a href='http://www.mactricksandtips.com/2009/06/quickly-close-terminal-windows.html' rel='bookmark' title='Permanent Link: Quickly Close Terminal Windows'>Quickly Close Terminal Windows</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>iTunes To Twitter AppleScript</title>
		<link>http://www.mactricksandtips.com/2008/06/itunes-to-twitter-applescript.html</link>
		<comments>http://www.mactricksandtips.com/2008/06/itunes-to-twitter-applescript.html#comments</comments>
		<pubDate>Tue, 24 Jun 2008 18:59:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apple Script]]></category>
		<category><![CDATA[iTunes]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://localhost:8888/?p=405</guid>
		<description><![CDATA[I'm starting to like Twitter. Its kind of fun, and a good way to keep up to date. I have a Mac Tricks And Tips Twitter feed, if you want to keep upto date with the latest posts, news and updates. I will probably be using it a lot over the next couple of days as this site is updated. Anyway, I have been playing around with a couple of AppleScripts that are really fun. They are designed to post your current iTunes track to Twitter. The potential to run up hundreds of tweets is bound to happen.<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2008/06/itunes-to-twitter-applescript.html">iTunes To Twitter AppleScript</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2008/08/using-twitterific-to-tweet-to-twitter.html' rel='bookmark' title='Permanent Link: Using Twitterific To Tweet To Twitter'>Using Twitterific To Tweet To Twitter</a></li>
<li><a href='http://www.mactricksandtips.com/2008/12/control-your-mac-with-twitter.html' rel='bookmark' title='Permanent Link: Control Your Mac With Twitter'>Control Your Mac With Twitter</a></li>
<li><a href='http://www.mactricksandtips.com/2009/05/tweetie-the-best-twitter-app-for-mac.html' rel='bookmark' title='Permanent Link: Tweetie &#8211; The Best Twitter App For Mac'>Tweetie &#8211; The Best Twitter App For Mac</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hey</p>
<p>I&#8217;m starting to like Twitter. Its kind of fun, and a good way to keep up to date. I have a <a href="http://twitter.com/mactricksandtip">Mac Tricks And Tips Twitter feed</a>, if you want to keep upto date with the latest posts, news and updates. I will probably be using it a lot over the next couple of days as this site is updated. Anyway, I have been playing around with a couple of AppleScripts that are really fun. They are designed to post your current iTunes track to Twitter. The potential to run up hundreds of tweets is bound to happen.</p>
<p>From my searching I have found two good AppleScripts, one that is more advance and for me never works and a second that is more manual but seems to work. I&#8217;m not an AppleScript genius so I couldn&#8217;t work out for the life of me what the problem was. These two scripts are <a href="http://www.leroux.ca/archive/dsp_view_474.cfm">Leroux&#8217;s</a> and <a href="http://tint.de/twitunes-applescript">Twi Tunes</a>.</p>
<p>Leroux&#8217;s personally seems a lot better. It automatically updates you Twitter account with the latest tune and then automatically refreshes it every couple of minutes. The problem is that it doesn&#8217;t work, there may have been a small problem between me copying the data across and compling it. I&#8217;ve gone through but no luck.</p>
<p>The second, TwiTunes, does work and is surprisingly simple. You download the script and place it in /Users/name/Library/iTunes/Scripts. You may need to create the folder scripts. It then, once as you click on it from the script icon in the menu bar, run, upload your tweet and finish. It does take your Safari keychain password so it is one more added step, as well as this it also does display a lot of messages, which does get annoying.</p>
<p><a href="http://bp1.blogger.com/_ZkO0uD8DlQA/SGFHCnek26I/AAAAAAAAEf4/Qnzn_62CQoU/s1600-h/Picture+1.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5215527953754282914" style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp1.blogger.com/_ZkO0uD8DlQA/SGFHCnek26I/AAAAAAAAEf4/Qnzn_62CQoU/s200/Picture+1.png" border="0" alt="" /></a><br />
Overall these two scripts seem half way there. I would rather take basic functionality over no functionality. I might take a hack at it tomorrow and see what I come up with. Tell me what you think of these sort of scripts. I know there is a lot for Quicksilver and Twitter, but i&#8217;m not to keen on QuickSilver, not my sort of application.</p>
<p>Edit: Leroux&#8217;s Apple Script does work. After kindly putting a download of the script and editing for myself it does what it says on the tin. I think it was down to a slight copy and pasting error with the extra space added here and there, as well as being impatient on my part. I did see the 3 minute time out in the code, although I didn&#8217;t really think about it. Check it out and annoy your friends with constant tweets of &#8220;great&#8221; and &#8220;up to date&#8221; music, as is the case with myself.</p>
<p>If you want to find out a bit more about Twitter and want to read a good book I recommend these two on Amazon, <a href="http://www.amazon.com/gp/product/0470479914?ie=UTF8&amp;tag=mact06-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0470479914">Twitter For Dummies</a> and <a href="http://www.amazon.com/gp/product/1600051189?ie=UTF8&amp;tag=mact06-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1600051189">Twitter Means Business</a>. Both are good books and I recommend you check them out.</p>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2008/06/itunes-to-twitter-applescript.html">iTunes To Twitter AppleScript</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2008/08/using-twitterific-to-tweet-to-twitter.html' rel='bookmark' title='Permanent Link: Using Twitterific To Tweet To Twitter'>Using Twitterific To Tweet To Twitter</a></li>
<li><a href='http://www.mactricksandtips.com/2008/12/control-your-mac-with-twitter.html' rel='bookmark' title='Permanent Link: Control Your Mac With Twitter'>Control Your Mac With Twitter</a></li>
<li><a href='http://www.mactricksandtips.com/2009/05/tweetie-the-best-twitter-app-for-mac.html' rel='bookmark' title='Permanent Link: Tweetie &#8211; The Best Twitter App For Mac'>Tweetie &#8211; The Best Twitter App For Mac</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Must Have Automator Action</title>
		<link>http://www.mactricksandtips.com/2008/03/must-have-automator-action.html</link>
		<comments>http://www.mactricksandtips.com/2008/03/must-have-automator-action.html#comments</comments>
		<pubDate>Fri, 07 Mar 2008 22:32:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apple Script]]></category>
		<category><![CDATA[Automator]]></category>
		<category><![CDATA[must have]]></category>

		<guid isPermaLink="false">http://localhost:8888/2008/03/must-have-automator-action.html</guid>
		<description><![CDATA[I have become fascinated with Automator, it is so powerful yet so simple. As a result if a bit of searching I have found a really good Automator action that you should install to aid with any workflows that you are creating.<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2008/03/must-have-automator-action.html">Must Have Automator Action</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2010/01/batch-resize-images-with-automator.html' rel='bookmark' title='Permanent Link: Batch Resize Images, With Automator'>Batch Resize Images, With Automator</a></li>
<li><a href='http://www.mactricksandtips.com/2009/01/introduction-to-automator-a-general-guide.html' rel='bookmark' title='Permanent Link: Introduction To Automator &#8211; A General Guide'>Introduction To Automator &#8211; A General Guide</a></li>
<li><a href='http://www.mactricksandtips.com/2010/01/add-itunes-media-with-services-and-automator.html' rel='bookmark' title='Permanent Link: Add iTunes Media With Services And Automator'>Add iTunes Media With Services And Automator</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hey</p>
<p>I have become fascinated with Automator, it is so powerful yet so simple. As a result if a bit of searching I have found a really good Automator action that you should install to aid with any workflows that you are creating.</p>
<p>Anyway I have found a really good Action which you can install into Automator to give your workflows a little extra punch. If you head over to <a href="http://www.automatedworkflows.com/software/automator_actions/system.html">Automated Workflows</a> you can download the small app to install your actions. Installing doesn&#8217;t take long and there is a little app that puts the action in the correct folder. There is a little niggle that hides all your applications, which was weird at first.</p>
<p>There are two action which you can install. Get clipboard contents, which gets your clipboard, pretty normal. And Type Keystroke which is very powerful. Normally to insert a keystroke you would have to add an Apple Script and then type <code> keystroke command + v</code>. This example would paste the text into what ever you are working on. The problem with this that it doesn&#8217;t always work. Every so often one would fail. This is where the action comes in. It has, so far worked every time.</p>
<p>If you want another method to press a key in Automator or Apple Script you can use keycodes command. This is slightly more complicated but enables you to press any key on the keyboard. This sometimes can&#8217;t be done using the above two methods. Key codes are the numeric values your system gives to every key press. As a result you can use it to press any key you want. If you want to use this command you have to type the following. This example is for pressing enter.</p>
<p><code>tell application "System Events"<br />      key code 36<br />  end tell</code></p>
<p>It is a little more complicated, you have to add it through an Apple Script in your workflow, but is a bit more powerful. You can with this little tip to press any key short cut in your Automator workflow. The download, has for me, been a great help.</p>
<p>If you have any other tips for Automator or Apple Script leave them below. I would love to hear them. This post, by the way, is the second time I have written it. The first disappeared much to great annoyance. As a result some people on email may not get it to tomorrow.</p>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2008/03/must-have-automator-action.html">Must Have Automator Action</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2010/01/batch-resize-images-with-automator.html' rel='bookmark' title='Permanent Link: Batch Resize Images, With Automator'>Batch Resize Images, With Automator</a></li>
<li><a href='http://www.mactricksandtips.com/2009/01/introduction-to-automator-a-general-guide.html' rel='bookmark' title='Permanent Link: Introduction To Automator &#8211; A General Guide'>Introduction To Automator &#8211; A General Guide</a></li>
<li><a href='http://www.mactricksandtips.com/2010/01/add-itunes-media-with-services-and-automator.html' rel='bookmark' title='Permanent Link: Add iTunes Media With Services And Automator'>Add iTunes Media With Services And Automator</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apple Script Random Number Generator</title>
		<link>http://www.mactricksandtips.com/2008/03/apple-script-random-number-generator.html</link>
		<comments>http://www.mactricksandtips.com/2008/03/apple-script-random-number-generator.html#comments</comments>
		<pubDate>Thu, 06 Mar 2008 21:19:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apple Script]]></category>
		<category><![CDATA[Maths]]></category>
		<category><![CDATA[Number]]></category>

		<guid isPermaLink="false">http://localhost:8888/2008/03/apple-script-random-number-generator.html</guid>
		<description><![CDATA[Having started to mess about in automator, I wanted to mess about more in Apple Script. This little trick will hopefully teach you how to generate a random number and display it in a message box.<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2008/03/apple-script-random-number-generator.html">Apple Script Random Number Generator</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2012/01/generate-random-numbers-in-terminalbash.html' rel='bookmark' title='Permanent Link: Generate Random Numbers In Terminal/Bash'>Generate Random Numbers In Terminal/Bash</a></li>
<li><a href='http://www.mactricksandtips.com/2010/01/reboot-into-bootcamp-script-applescript-app.html' rel='bookmark' title='Permanent Link: Reboot Into BootCamp &#8211; Script, AppleScript, App'>Reboot Into BootCamp &#8211; Script, AppleScript, App</a></li>
<li><a href='http://www.mactricksandtips.com/2008/09/phone-home-anti-robber-mac-security-script.html' rel='bookmark' title='Permanent Link: Phone Home Anti-Robber Mac Security Script'>Phone Home Anti-Robber Mac Security Script</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hey</p>
<p>Having started to mess about in <a href="http://www.mactricksandtips.com/2008/03/creating-basic-clickbot.html">automator</a>, I wanted to mess about more in Apple Script. This little trick will hopefully teach you how to generate a random number and display it in a message box. The first step is to open Apple Script Editor. Go to Applications > Apple Script > Script Editor.</p>
<p>You are now on the code screen. You can now enter the random number generator piece of code. This is defined by <code>random number</code>. Insert this into the code into the code view. Your random number generator is now done. At the moment it isn&#8217;t very useful.</p>
<p>To make the random number generator a bit more useful we are going to display this number through a dialog box. First we need to set the variable for the random number and then display it through the use of a dialog box. The give up after 2 will automatically make the box disappear.</p>
<p><code><br />set rn to (random number) as text<br />display dialog rn giving up after 2</code></p>
<p>You can of course change the variables for the random number. At the moment it will display a number between 0 and 1. This can be changed using the following syntax.</p>
<p><code>random number from 1 to 10</code></p>
<p>The first number can also be a minus as well. This will of course generate some minus numbers as well. Like with any random number generator you can use a seed value. Usually most random number generator will use either a CPU cycle number or the time to start the number generation. You can use a starting seed value for the random number. This is done through the syntax:</p>
<p><code>random number from -10.0 to 10 with seed 12 </code></p>
<p>You can now generate random numbers all you like. For a final touch you can add a variable so the random number is copied to the clipboard. This is really simple you just add the following piece of code to the end of the code.</p>
<p><code>set the clipboard to rn</code></p>
<p>The final code now looks like this.</p>
<p><code>set rn to (random number from 1 to 10 with seed 2) as text<br />set the clipboard to rn<br />display dialog rn giving up after 2<br /></code><br />If you know any more random number generation techniques with Apple Script please leave a comment below.</p>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2008/03/apple-script-random-number-generator.html">Apple Script Random Number Generator</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2012/01/generate-random-numbers-in-terminalbash.html' rel='bookmark' title='Permanent Link: Generate Random Numbers In Terminal/Bash'>Generate Random Numbers In Terminal/Bash</a></li>
<li><a href='http://www.mactricksandtips.com/2010/01/reboot-into-bootcamp-script-applescript-app.html' rel='bookmark' title='Permanent Link: Reboot Into BootCamp &#8211; Script, AppleScript, App'>Reboot Into BootCamp &#8211; Script, AppleScript, App</a></li>
<li><a href='http://www.mactricksandtips.com/2008/09/phone-home-anti-robber-mac-security-script.html' rel='bookmark' title='Permanent Link: Phone Home Anti-Robber Mac Security Script'>Phone Home Anti-Robber Mac Security Script</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Creating A Basic Clickbot</title>
		<link>http://www.mactricksandtips.com/2008/03/creating-basic-clickbot.html</link>
		<comments>http://www.mactricksandtips.com/2008/03/creating-basic-clickbot.html#comments</comments>
		<pubDate>Tue, 04 Mar 2008 17:13:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apple Script]]></category>
		<category><![CDATA[Automator]]></category>

		<guid isPermaLink="false">http://localhost:8888/2008/03/creating-a-basic-clickbot.html</guid>
		<description><![CDATA[Although the titles sounds like some l33t hacking tool, aimed at destroying some vital computer system, this post will be a little mundane. For a while I was searching Google for a way to build a click bot on my Mac. I didn't want to use it for something malicious, I was just interested after coming across a couple of articles on this subject. To actually create a click bot requires literally only a couple of steps. I was amazed at myself for my own stupidity when I managed to find out how to do it.<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2008/03/creating-basic-clickbot.html">Creating A Basic Clickbot</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>



Related posts:<ol><li><a href='http://www.mactricksandtips.com/2009/09/creating-bootable-backups-for-your-mac.html' rel='bookmark' title='Permanent Link: Creating Bootable Backups For Your Mac'>Creating Bootable Backups For Your Mac</a></li>
<li><a href='http://www.mactricksandtips.com/2007/05/creating-alias-on-ntfs-drive.html' rel='bookmark' title='Permanent Link: Creating an Alias on an NTFS Drive'>Creating an Alias on an NTFS Drive</a></li>
<li><a href='http://www.mactricksandtips.com/2008/03/must-have-automator-action.html' rel='bookmark' title='Permanent Link: Must Have Automator Action'>Must Have Automator Action</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hey</p>
<p>Although the titles sounds like some l33t hacking tool, aimed at destroying some vital computer system, this post will be a little mundane. For a while I was searching Google for a way to build a click bot on my Mac. I didn&#8217;t want to use it for something malicious, I was just interested after coming across a couple of articles on this subject. To actually create a click bot requires literally only a couple of steps. I was amazed at myself for my own stupidity when I managed to find out how to do it.</p>
<p>To create a click bot you need to use a program on your system called Automator. Automator is one of those programs that is really powerful, but is hardly ever advertised. It is shown on the Apple website but is usually replaced by more &#8220;shiny&#8221; programs such as iLife which appeal towards the masses.</p>
<p>The first step in creating a click bot is to open Automator. This is located in Applications > Automator. When the program opens you will be greeted with a simple interface. On top of this is a pop up window asking if you want to chose a Custom workflow, File &amp; Folder workflow, Music, Photos or Text. Chose custom for this exercise.</p>
<p>You will then be greeted with the main interface. On the left you have the draw where you can pick and chose from a library of inputs. The right hand side is the workflow page. Automator is massive. I could write an entire website on Automator and in fact there <a href="http://automatorworld.com/">is</a>, there are also loads of books on the subject. Anyway the point of this post is to lightly skim the surface on this topic.</p>
<p>To record the click bot we are going to use the record user interface events button. It is a simple way to record what you want to do. Alternatively you could use the library on the left, but this way is much quicker. The record button is located in the top right corner of the toolbar.</p>
<p><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_ZkO0uD8DlQA/R82FwyjVO5I/AAAAAAAAEDw/VGPzlpDGmIo/s1600-h/Picture+1.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp3.blogger.com/_ZkO0uD8DlQA/R82FwyjVO5I/AAAAAAAAEDw/VGPzlpDGmIo/s200/Picture+1.png" alt="" id="BLOGGER_PHOTO_ID_5173938620168747922" border="0" /></a><br />Press the record button. If you have used record macro events in programs such as Word or Excel you may know how this works. At the moment automator is recording all of the user interface click and typing events. Every time you click on a window, button, select a piece of text etc it will record what happens. But it doesn&#8217;t record time between the clicks.</p>
<p>To record your click bot do exactly what you want to do. I am going to record on where it opens Google, types some text and presses search. Very simple. You will notice during the recording a small floating widget that appears on top of everything. Once as you are finished with your click bot your can press stop.</p>
<p><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_ZkO0uD8DlQA/R82QTSjVO6I/AAAAAAAAED4/v2fP0i5rOF0/s1600-h/Picture+2.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp1.blogger.com/_ZkO0uD8DlQA/R82QTSjVO6I/AAAAAAAAED4/v2fP0i5rOF0/s200/Picture+2.png" alt="" id="BLOGGER_PHOTO_ID_5173950207990512546" border="0" /></a><br />That is it, your workflow click bot is done. Click the play button and it will play it back following the exact mouse movements. You can now do it for anything you want. You can also speed it up to run in double time.</p>
<p>There of course some limiting factors. It follows your mouse movements. So if you move stuff about it might not work. What I recommend you do it just play. Mess about with the settings, the variables. Change somethings about, see what happens. You could eventually make a sophisticated click bot from the workflow window.</p>
<p>If you have any comments, tips or tricks let me know below. I would love to hear them. In the mean time I am off to play and conquer the world through automator.
<div class="blogger-post-footer"><br/>This post is from <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a><br />
<br/></div>
<p>Want to catch up on the latest <a href="http://www.twitter.com/mactricksandtip">Tweets</a> about this site, follow me on Twitter.
<br /><br/>You have just read <a href="http://www.mactricksandtips.com/2008/03/creating-basic-clickbot.html">Creating A Basic Clickbot</a>,<br /><br/>On <a href="http://www.mactricksandtips.com">Mac Tricks And Tips</a> - The site all about Mac Tips, Tricks, Tools, Guides and so much more. </p>


<p>Related posts:<ol><li><a href='http://www.mactricksandtips.com/2009/09/creating-bootable-backups-for-your-mac.html' rel='bookmark' title='Permanent Link: Creating Bootable Backups For Your Mac'>Creating Bootable Backups For Your Mac</a></li>
<li><a href='http://www.mactricksandtips.com/2007/05/creating-alias-on-ntfs-drive.html' rel='bookmark' title='Permanent Link: Creating an Alias on an NTFS Drive'>Creating an Alias on an NTFS Drive</a></li>
<li><a href='http://www.mactricksandtips.com/2008/03/must-have-automator-action.html' rel='bookmark' title='Permanent Link: Must Have Automator Action'>Must Have Automator Action</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

