THE Apple Script guide (#1) (Hack-A-Mac)

Discussion in 'Code Snippets and Tutorials' started by Fexxel, May 14, 2009.

  1. Fexxel

    Fexxel Level IV

    Joined:
    Jan 28, 2009
    Messages:
    959
    Likes Received:
    26
    THE Apple Script Guide (#1)
    by Fexxel​

    This is an introductory tutorial. Not advanced.
    Step 1: Get the app!
    First off, you need a way to write these scripts, and run them.
    AppleScript:
    Features of Apple Script:
    It comes with a mac Computer. If you have a PC- too bad. Sucks for you.
    [​IMG]
    That's what the main window looks like.
    Now, notice the main frame. I will try to make this as simple as possible:
    [​IMG]
    Model: (insert items, and get rid of the { and }'s...)
    Code (Text):
    1. tell {"application here"}
    2. {command}
    3. end tell
    Syntax:
    • tell
      end tell
    • repeat
      end repeat
    Here are some example snip's for ya:
    Code (Text):
    1.  
    2. tell application "safari"
    3. activate
    4. delay 1
    5. do javascript "window.open('http://www.google.com/")
    6. delay 4
    7. keystroke "t"
    8. keystroke "h"
    9. keystroke "i"
    10. keystroke "s"
    11. keystroke space
    12. keystroke "i"
    13. keystroke "s"
    14. keystroke space
    15. keystroke "a"
    16. keystroke space
    17. keystroke "t"
    18. keystroke "u"
    19. keystroke "t"
    20. keystroke "o"
    21. keystroke "r"
    22. keystroke "i"
    23. keystroke "a"
    24. keystroke "l"
    25. keystroke space
    26. keystroke "b"
    27. keystroke "y"
    28. keystroke space
    29. keystroke "f"
    30. keystroke "e"
    31. keystroke "x"
    32. keystroke "x"
    33. keystroke "e"
    34. keystroke "l"
    35. end tell
    36.  
    37.  
     
  2. lazypando

    lazypando Level IV

    Joined:
    Nov 16, 2006
    Messages:
    3,326
    Likes Received:
    94
    hey fexxel...do you know objective c?
     
  3. Fexxel

    Fexxel Level IV

    Joined:
    Jan 28, 2009
    Messages:
    959
    Likes Received:
    26
    The only bit of objective c I know was for Cocoa.