Re: AppleScript Timed Events
Re: AppleScript Timed Events
- Subject: Re: AppleScript Timed Events
- From: John Delacour <email@hidden>
- Date: Tue, 17 Jun 2003 11:15:46 +0100
- Mac-eudora-version: 6.0a21
At 11:27 pm -0700 16/6/03, Simone Manganelli wrote:
Anybody know how to do timed events with AppleScript? As far as my
knowledge of AppleScript goes (I think it's pretty good, anyway),
the closest thing you can do is an on/end idle loop with a "delay
15" line or whatever, and then just check for a condition, like a
certain time or date.
I get the feeling you've never actually used it. 'delay' doesn't
come into it, and the idle handler can do everything you need,
probably far more conveniently than the use of any external utility.
You can put a stay-open applet like the one below in your login
items. This applet simply displays the path of the script to run
when the scheduled time has been exceeded; in practice you would add
code to run the script and remove the item from the agenda list or
something like that.
To change the agenda (a list of records) at any time you would simply
send an apple event to change the property or to add to the agenda
you would do
tell app "appname" to set end of agenda to {tstring:"25/12", _script:"Noel"}
The tstring property of the agenda items is any unambiguous string.
You might like to keep your agenda as tab-delimited text file
tstring1 \t _script1
tstring2" \t _script2
...
and parse this to create the agenda property to send to the applet.
(* STAY OPEN APPLET *)
property agenda : {{tstring:"17 jun 03, 9am", _script:"beep.scpt"}}
property _me : path to me
property _folder : ""
on run
tell app "Finder" to set _folder to "" & container of _me
idle
end run
on idle
set _now to current date
repeat with _record in agenda
set _time to date (tstring of _record)
set _action to _script of _record
if _time is less than _now then
display dialog _folder & _action
end if
end repeat
return 5 * minutes
end idle
--JD
.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.