AppleScript Programming

Discussion in 'Mac Programming' started by Emilio454, Jan 1, 2008.

  1. Emilio454 macrumors newbie

    Joined:
    Jan 1, 2008
    #1
    I use applescript to do apps but the thing is that i don't know how to use it :s
    Can someone please make me a tutorial please?

    Thanks, Emilio.
     
  2. HiRez macrumors 603

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #2
    You're joking, right? AppleScript is a huge subject. You are basically asking for someone to teach you how to be a programmer. That's like saying "Please make me a tutorial on how to be an airline pilot." It's not going to happen. Start with some books, such as AppleScript: The Comprehensive Guide to Scripting and Automation on Mac OS X. There may also be a few online tutorials to help get you started, such as those on the MacScripter site, but it's not something you can learn overnight.
     
  3. Emilio454 thread starter macrumors newbie

    Joined:
    Jan 1, 2008
  4. Macgenie macrumors newbie

    Joined:
    Jan 8, 2008
    Location:
    Suffolk, UK
    #4
    Hi Emillio - as stated, Applescript is a BIG topic and can be hard to get on with - it can be very much a case of trial and error and poring over dictionaries to see what can be done. You need to have a good idea of what you are trying to achieve and then break it down into small steps - some scripters do amazing things with Applescript but if you want to really get to grips with a Mac I would suggest you learn Cocoa & Objective C instead.

    I have included a short script below which automates the clearing out of Appleworks alias files (every time an Appleworks doc is opened it creates an alias - as these build up Appleworks tends to get slower and slower so every now and then it pays to trash the alias files. My code:

    tell application "Finder"
    make new Finder window
    tell application "Finder"
    activate
    move every file of folder "Recent items" of folder "Starting Points" of folder "AppleWorks User Data" of folder "Documents" of folder "XXXXXX" of folder "Users" of startup disk to trash

    end tell
    close Finder window 1
    end tell

    Note - replace "XXXXXX" with the name of your Mac account for this to work.

    Even this short piece of code took some time to work out; Applescript is not very intuitive and the dictionaries take some getting used to, the syntax can seem strange at times and not all applications respond to Applescript fully.

    Hope this helps :)
     
  5. dstearns96 macrumors member

    dstearns96

    Joined:
    Dec 16, 2007
    #5
    do a command+F search in finder and narrow it to script types. here is a visual. open some of these and take some code from them and put it together to make something, you can learn from these things
     

    Attached Files:

Share This Page