Pinterest Stumbleupon Whatsapp
Ads by Google

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

Ads by Google

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.

  1. Bob
    December 15, 2010 at 11:34 am

    I as well have 10.6.5 and do not have the above noted info scripts>default actions.
    Perhaps this is no longer offered in Snow Leopard?
    I will instal your copy from dropbox. Thanks for sharing.

  2. Arjay67
    November 30, 2010 at 2:55 pm

    Will part 2 be coming soon?

  3. Bakari
    October 28, 2010 at 5:55 pm

    tg108, sorry about that. I'm not sure why those files showed up on my computer and it's not showing up on others. I checked the default settings of Snow Leopard and they should have been there. Anyway, you can download them here: http://dl.dropbox.com/u/252347...

  4. Bakari
    October 28, 2010 at 3:55 pm

    tg108, sorry about that. I'm not sure why those files showed up on my computer and it's not showing up on others. I checked the default settings of Snow Leopard and they should have been there. Anyway, you can download them here: http://dl.dropbox.com/u/252347/Scripts.zip

    • Bob
      December 15, 2010 at 10:34 am

      I as well have 10.6.5 and do not have the above noted info scripts>default actions.
      Perhaps this is no longer offered in Snow Leopard?
      I will instal your copy from dropbox. Thanks for sharing.

      • Bakari
        December 15, 2010 at 5:09 pm

        Yeah, this must be the case. I know for sure that it was installed by default in my OS, but I'm not sure why it's not showing up now. Thanks for letting me know.

  5. tg108
    October 28, 2010 at 4:42 am

    I'm using 10.6.4 and also do not have the info scripts > default actions

  6. Zane
    October 23, 2010 at 6:55 pm

    Ok, so I got through the whole thing, and I have to say, it is AWESOME! I can really use this! Can't wait for the next one! Keep up the good work, Bakari!

  7. Zane
    October 23, 2010 at 6:54 pm

    Ok, so I got through the whole thing, and I have to say, it is AWESOME! I can't really use this! Can't wait for the next one! Keep up the good work, Bakari!

  8. Bakari
    October 23, 2010 at 6:53 pm

    Cool, Zane. Glad it works. I'm still not sure why the default files were not in your system. I'm wondering if my default AppleScript scripts were carried over from previous versions of the OS X? I can't understand why Apple would stop including them.

    • Zane
      October 23, 2010 at 7:21 pm

      Yes, I tried to carry over information from my old computer, but it didn't work. Because I got halfway through and it died. So i just started from scratch, but I think a couple of the old system things are still on this computer...if you can translate all that...

  9. Zane
    October 23, 2010 at 6:48 pm

    Ok, beautiful, I downloaded that, and dragged it into Macintosh HD:Library, and it worked!

  10. Bakari
    October 23, 2010 at 5:35 am

    Hmmm, that's weird. Did you check Library > Scripts?
    If not there, I posted them on my dropbox account. You can download and put them in your Scripts folder: http://dl.dropbox.com/u/252347...
    What version of Mac OS X are using?

  11. Bakari
    October 23, 2010 at 3:35 am

    Hmmm, that's weird. Did you check Library > Scripts?
    If not there, I posted them on my dropbox account. You can download and put them in your Scripts folder: http://dl.dropbox.com/u/252347/Scripts.zip
    What version of Mac OS X are using?

    • Marta
      October 23, 2010 at 7:11 am

      Couldn't find it either (OS 10.6.4).

  12. Zane
    October 23, 2010 at 2:43 am

    I don't have the default actions or finder's script folders on mine.

Leave a Reply

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