An AppleScript that does some useful things at startup

Jan 30, '04 08:43:00AM

Contributed by: RedEyedEnglisher

Here's something for automating a few useful things at startup. Tested on a Panther system, but should be fine for Jaguar.

This script says hello, starts playing a random track, tells you what it's playing, connects to the internet (delay is for dial uppers), loads a webpage, checks for new mail, and says if you have any.

I hope someone else finds this useful. Read the rest of the article for the script...

Create this in Script Editor, and save it as a compiled script, then place it in your startup items folder.


set theDate to current date
set theDay to weekday of theDate
set theTime to time of theDate

if the theTime ? 0 and the theTime < 43200 then say ¬
  "Good morning! It's " & theDay & "."
if the theTime > 43199 and the theTime < 57600 then say ¬
  "Good afternoon!"
if the theTime > 57599 and the theTime < 64800 then say ¬
  "Good evening!"
if the theTime > 64799 and the theTime < 86400 then say ¬
  "It's " & theDay & " night."

delay 2
say "I'll put some music on"

tell application "iTunes"
  activate
  set sound volume to 75
  set theTrack to some file track of user playlist "All"
  set theTrackName to name of theTrack
  set theTrackArtist to artist of theTrack
  play theTrack
  set collapsed of window 1 to true
end tell

tell application "iTunes"
  activate
  set sound volume to 15
  say "This is " & theTrackName & ", by " & ¬
    theTrackArtist & ". "
  set sound volume to 75
end tell

tell application "Internet Connect"
  connect
end tell

delay 20

property theURL : "http://macosxhints.com"
open location theURL

tell application "Mail"
  check for new mail
  
  delay 30
  set unreadCount to unread count of inbox
  tell application "iTunes"
    set sound volume to 15
    delay 1
    if unreadCount is equal to 0 then say ¬
      "You have no new messages!"
    if unreadCount is equal to 1 then say ¬
      "You have a new message!"
    if unreadCount is greater than 1 then say ¬
      "You have " & unreadCount & " new messages!"
    delay 1
    set sound volume to 75
  end tell
end tell

Comments (2)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20040121190206422