Introduction: Simple Applescript Tutorial

Picture of Simple Applescript Tutorial

 Hey everyone! Here is a simple Applescript tutorial for making popup dialogs.

The 4/13/10 update includes three new scripts, and how to save them. A special thanks to Marble of Doom for the first new one!

Step 1: You Will Need...

Picture of You Will Need...

 1) A Mac (Sorry PC's... I'll have another tut for you guys later.)
 2) Applescript. It should come standard with all Mac's

Step 2: Open a New Script

Picture of Open a New Script

 Fire up Applescript and type the following in:
-Display dialog (This tells the computer that it is going to make a popup dialog)
-"Text goes here" (Anything within the quotes is what will appear in the dialog)

Step 3: Adding More Lines

Picture of Adding More Lines

 Now do the same just start a new line every time.

 This is good for making fake viruses, but is pointless because Mac's don't get viruses!!!

Step 4: Now Test

Picture of Now Test

 Just click run and it should start. 

Make sure it looks like the below:

Step 5: Applescript Number 2

Picture of Applescript Number 2

 Here is another applescript brought to my attention by Marble of Doom (

It basically keeps putting more and more folders on the desktop, until you force quit it. And sorry, I will not demonstrate it. 

***DISCLAIMER*** If you really mess up your computer, it is not mine, nor Marble of Doom's fault, it is yours

Step 6: The Repeat

Picture of The Repeat

 The Repeat command tells Script Editor to keep doing whatever you tell it to, in this case, making folders

Step 7: The Beep

Picture of The Beep

 To be honest, I have NO idea what this does, but after some googleing, I found the beep command just makes the Mac's default error beep (You may not of heard this beep, because you probably haven't had an error)

Step 8: The Command

Picture of The Command

 Here is when the computer starts making folders. Here is what each of the commands will do.
  1. tell application "Finder"
    This simply tells Finder to pay attention  
  2. make new folder at desktop
    This tells Finder to start making folders
  3. end tell
    This tells Finder that it isn't going to get any more commands, but to keep making folders

Step 9: Finishing Off

Picture of Finishing Off

 Just hit the "Compile" button, and save it, if you dare. THE ONLY WAY TO STOP THIS IS TO FORCE QUIT IT

Step 10: Simplest of Them All Is...

Picture of Simplest of Them All Is...

 The Shutdown script!!! This is really simple.

Step 11: Here Is How to Do It

Picture of Here Is How to Do It

 Simple. Just type in 

tell application "Finder" to shut down

This simply shuts down the computer.

Step 12: Lastly, Opening Pages in Safari

Picture of Lastly, Opening Pages in Safari

 Lastly, here is how to open a webpage in 

Type in: tell application "Safari" to open
                 open location ""

You can type in as many websites as you want, which can get really annoying

Step 13: Saving

Picture of Saving

 So you have read through all of these scripts, but how do you save them?

Well, you can save it as a script, that opens in Script Editor, an Application, or a text file

To save, you go to File> Save or File> Save As... and select what you want to name it and save it as.


godofallcows (author)2010-10-18

Holy hell. Are you that stupid to actually believe macs don't get viruses?

101lenny101 (author)godofallcows2010-12-11

I am in no mood to argue with you. I obviously know that Mac's CAN get viruses, but are not known for getting viruses as much as Windows. I know with every OS comes a flaw. Windows, Mac, and Linux all have them. Its just that in my opinion, Mac and Linux are most secure. By the way, thanks for using proper grammar.

Element1604 (author)2010-08-25

what are some good ways to learn more about using/ making applescript?

101lenny101 (author)Element16042010-08-26

There are quite a few resources to learn Applescript. Some of the best ways are on the internet. Start with Googling. There you will find some basic tutorials. STAY AWAY FROM YOUTUBE!!! These are the worst Applescript "tutorials" out there, because they just give you the code and don't explain it. Once you have found some basic tutorials on the internet via different websites, and understand some basic commands, variables, etc., look for PDF tutorials. These are probably going to be the more detailed of all the free methods. Those are the free resources. If you really want to learn about applescripting, books are your best bet. And in my opinion, a book I am reading now called "AppleScript: A comprehensive Guide To Scripting and Automation on Mac OS X" and it is written by Hanaan Rosenthal. This book is very thorough.

Marble of Doom (author)2010-01-17

The simplest and most annoying scripts are the ones with the repeat command. They take the form of:
(what you want to repeat)
end repeat

Repeat commands will loop indefinitely unless an error occurs or you force-quit it so be careful!! It's easy to make a loop that you are unable to stop.

The most INFURIATING repeating script is (plz be careful!) this:
    tell application "Finder"
        make new folder at desktop
    end tell
end repeat

You have a nice start for your instructable, but I think it needs more. You only list one example. Maybe you could include mine as well as others you you create or find on the internet. 2*'s for now until you work on this some more.

 Thank you for your feedback. I appreciate your input, and will use your example. I will update this soon. An I will be careful not to use the new folder one. I have a Mac and a PC (I like Mac's WAY better, don't get me wrong) and I made a batch file similar to that of your example.