I am trying to create an applescript that is launched (via crontab) at 6am to be used as an alarm clock. however I am running into some trouble with a repeat block. I have the script opening up iTunes and playing the alarm playlist, while displaying a dialog. I would like to have the dialog displayed until the Button "OK’ is returned. Meanwhile, iTunes is playing and the dialog still stays visible, i would like to have the computer talk to me and say “Time to wake up!” every 20 sec. It seems when i try to execute the script, it skips over my repeat loop. I have tried different ways to accomplish this, but I am stuck. Any suggestions?
-- WEEKDAY
set theDate to current date
set theDay to weekday of theDate as string
set theWeekday to theDay = "Monday" or theDay = "Tuesday" or theDay = "Wednesday" or theDay = "Thursday" or theDay = "Friday"
if theWeekday then
tell application "iTunes"
play playlist "Alarm"
end tell
delay 10
set timeToWakeUp to display dialog "Time to wake up!" buttons {"Snooze", "OK"} default button "OK"
set answer to button returned of timeToWakeUp
repeat until answer is "OK"
tell application "iTunes" to set sound volume to minVol
delay 0.5
say "Time to wake up sir!"
delay 0.5
tell application "iTunes" to set sound volume to maxVol
delay 30
end repeat
if answer is "OK" then
tell application "iTunes"
quit
end tell
end if
end if
Model: 2007 Macbook Pro
AppleScript: 2.3
Browser: Safari 531.22.7
Operating System: Mac OS X (10.6)