Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

An AppleScript that does some useful things at startup System
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
    •    
  • Currently 1.75 / 5
  You rated: 2 / 5 (4 votes cast)
 
[7,537 views]  

An AppleScript that does some useful things at startup | 2 comments | Create New Account
Click here to return to the 'An AppleScript that does some useful things at startup' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript that does some useful things at startup
Authored by: afvdk on Feb 03, '04 08:44:39AM
My iTunes files are on a mp3 server here, that connects through samba. Hence, I need to mount the server before I can play the files. So I added to the script (before calling iTunes):


tell application "Finder"
activate
mount volume "smb://USERNAME@SERVER/SHARE/"
end tell

where USERNAME, SERVER and SHARE have to be replaced with their respective values for you. Does anyone know howto tell iTunes to play from the whole library, instead of a playlist? Greetings....

[ Reply to This | # ]

An AppleScript that does some useful things at startup
Authored by: RedEyedEnglisher on Feb 14, '04 07:30:29AM

I've noticed that uploading this script to the page has garbled some stuff. Updated now as well. ***Note, the '?' after the first 'if' statement should be a 'greater than or equals' but never seems to come out the right way when I upload *** Try this. Works on Jaguar as well as Panther. Email me if any problems or suggestions for enhancements.

(*"Wotcher" - A Splendid Start Up Applescript (SSUA) for those too lazy to type or read much when they switch the computer on *)

(* Open for any kind of sauce (c) licence. Hope you enjoy. mattbrook@mac.com. If you want to send me banknotes do it via paypal, or even an email to say "I hate this it doesn't work." Absolutely no support or warranty given whatsoever *)

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 Dave! It's " & theDay & "."
if the theTime > 43199 and the theTime < 57600 then say "Good afternoon gentlemen, I am a Hal 9000 computer!"
if the theTime > 57599 and the theTime < 64800 then say "Good evening Dave, I'm sorry but I don't think I can let you do that!"
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
set miniaturized of window 1 to true
end tell

delay 20

property theURL : "http://www.b3ta.com"
open location theURL

tell application "Safari" (* or whatever browser you use *)
set miniaturized of window 1 to true
end tell

tell application "Mail"
check for new mail
set miniaturized of window 1 to true

delay 30
set unreadCount to unread count of inbox
tell application "iTunes"
set sound volume to 15
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!"
set sound volume to 75
end tell
end tell



[ Reply to This | # ]