Pinterest Stumbleupon Whatsapp
Advertisement

applescript tutorialMost computer users know how tedious it can be to perform menial and repetitive tasks like launching applications and web pages, inserting data into text fields, resizing image files, and typing out frequently used words.

Many of us perform larger and more intensive tasks involving two or more applications and several clicks or keyboard shortcuts. That’s why applications like Apple”˜s classic AppleScript application has been a favorite among many users because of it’s almost English-like programming language.


AppleScript is an automation program which is not as user-friendly as Apple”˜s drag-and-drop Automator program but much faster and allows to build complex automations.

AppleScript comes installed by default in all version Apple”˜s OS X software, and there are many resourceful websites which can help you learn how to use the program.

If you’re new to AppleScript and are curious about it, let’s take a few minutes to see what it has to offer.

AppleScript In Action

AppleScript can be found the Utilities folder, which is in the Applications folder of your Mac. Launch AppleScript so that you can get started with some pre-installed scripts. (By the way, you might want to drag AppleScript to your dock so that you can easily access it during and after this tutorial. You can also just drag the application out of the utilities folder and put it in the list of other applications.)

Advertisement

applescript tutorial

After you launch AppleScript, open its Preferences and click the “Show Script menu in menu bar” and “Show Computer scripts” boxes.

In your Finder’s menu bar, you’ll see the AppleScript folder icon. Click on it and then select Default Actions > Info Scripts folder. (Notice also that there’s a menu item titled, Open AppleScript Editor, which is another way you can launch AppleScript.)

how to applescript

Now click on the Current Date & Time script, and it should display that information with an option to copy that data to your clipboard. That is just one very small example of what AppleScript can do.

how to applescript

Now go back and click on the Info Scripts folder again, but this time just click and release on the folder itself so that it will open.

how to applescript

Double-click on the Current Date & Time script to open it in the AppleScript Editor. Underneath some copyright language, you’ll see the lines of script that caused the data to display. As you read each line of the script, you’ll see that many parts of it read almost like a regular English sentence (e.g., “display dialog the date_stamp buttons {“Clipboard”, “OK”) default button 2”).

For an AppleScript beginner, this code may appear a little too complex, but it’s certainly easier to understand than many other programming languages, such as Objective-C.

Opening Web Sites

Okay, let’s run an easier script. Go back to the AppleScript folders in the menu bar and select ï»¿Default Actions > URLs. Open the folder and then click on one of the scripts, such as “Apple Store.scpt”.

how to write applescript

Click the Run button in the toolbar and AppleScript should launch the targeted URL.

There’s another way to write that script so that it makes a little more sense. Let’s learn how. Select File > New in AppleScript and type, or copy and paste, the following lines of script exactly:

tell application “Safari”

activate

open location “http://www.apple.com/”

end tell

If you want, you can add several more URLs using the same line of instructions, (e.g. “open location “http://www.makeuseof.com”) and then save the script as an application in order to launch all your targeted URLs at once.

applescript tutorial

Okay, let’s stop for now. In part 2 of this article, I will present some really cool, simple, and practical AppleScripts, and also tell you where you can find more information to start learning the language.

If you use AppleScript, let us know about a few of your favorite automations.

Leave a Reply

Your email address will not be published. Required fields are marked *