Cool AppleScripts!

  • Avatar

    Posted: 04 February 2002 01:29 PM

    AppleScript is a skill you need to keep fresh in your mind.  Example scripts are a great way to learn more about AppleScript.  This thread is for cool scripts that you’ve found.  Promote the power of AppleScript! 

    Now for the Cool AppleScript:

    I came across a cool script the other day.  This script will open iTunes 2, set the volume, and start playing songs off one of your playlists.  Remember to change “blues” to the name of whatever your playlist is called (such as “jazz”).  This script comes from John Welch.

    tell application “iTunes”
      activate
      set sound volume to 50—range is 0 to 100
      set myPlayList to playlist “Blues”
      play myPlayList
    end tell

         
  • Avatar

    Posted: 04 February 2002 01:29 PM #1

    This CoolScript? also takes advantage of iTunes’s AppleScript functions.  This idea popped up on a mailing list I read.  Someone likes to listen to iTunes while reading mail in Entourage.  Because, both apps are scriptable he thought he wanted AppleScript to create a line in his message at the end telling the reader what he was listening to when he sent the message.  It’s really fun!

    tell application "Finder"
        
    if (get name of every processcontains "iTunes" then
            tell application 
    "iTunes"
                
    set theName to the name of the ?class pTrk?
                
    set theArtist to the ?class pArtof the ?class pTrk?
                
    set theAlbum to the ?class pAlbof the ?class pTrk?
            
    end tell
    (*if iTunes isn't running the script will realize it can'do anything and will quit*)
            
            
    set theNewSig to "--
    I'm listening to " 
    theName " by " theArtist " off of " theAlbum
    tell application 
    "Microsoft Entourage"
        
    if class of window 1 is draft window then
            set content of window 1 to 
    (content of window 1 & return & theNewSig)
            
    send window 1
        end 
    if
    (*
    This script can only work while you are in the draft window typing up your message or right before you hit the send button.*)    

    end tell
    end 
    if
    end tell 

    Compile the script and put it in your E’rage script menu.  Then when you are done typing your message, select this script.  The script will add the iTunes line and send your message.  Have fun!