12,297
edits
m (→AppleScript) |
|||
Line 64: | Line 64: | ||
play document "my_sound.wav" | play document "my_sound.wav" | ||
end tell | end tell | ||
</source> | |||
To time events use iCal and run scripts on specific (repeating) entries. This creates <tt>launchd</tt> events. Alternatively use <tt>launchd</tt> directly. If you have an AppleScript running in a loop you may want to exit this loop at a specific time like this: | |||
<source lang="applescript"> | |||
repeat | |||
set currentMinute to minutes of (current date) | |||
set currentHour to hours of (current date) | |||
if (currentHour = 17) then | |||
if (currentMinute > 50) then | |||
tell application "System Events" | |||
shut down | |||
exit repeat | |||
end tell | |||
end if | |||
end if | |||
delay 0.3 | |||
end repeat | |||
</source> | </source> | ||