Simple Applescript Tutorial

by 101lenny101 in Circuits > Apple

21084 Views, 10 Favorites, 0 Comments

Simple Applescript Tutorial

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

***UPDATE***
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!

You Will Need...

Script Editor.png
 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

Open a New Script

Untitled.png
Untitled DisplayDialog.png
Untitled Display Dialog complete.png
 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)

Adding More Lines

Untitled MoreLines.png
 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!!!

Now Test

1.png
2.png
3.png
4.png
 Just click run and it should start. 

Make sure it looks like the below:

Applescript Number 2

Script Editor.png
 Here is another applescript brought to my attention by Marble of Doom (www.instructables.com/member/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

The Repeat

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

The Beep

beep.png
 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)

The Command

Finishing.png
 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


Finishing Off

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

Simplest of Them All Is...

Script Editor.png
 The Shutdown script!!! This is really simple.

Here Is How to Do It

Shutdown.png
 Simple. Just type in 

tell application "Finder" to shut down

This simply shuts down the computer.

Lastly, Opening Pages in Safari

Many.png
 Lastly, here is how to open a webpage in 
Safari.

Type in: tell application "Safari" to open
                 open location "https://www.instructables.com/"

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

Saving

File....png
Name.png
File Type.png
 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.