start and stop a script in ical

i have a script,
looping an endless repeat.

i want to start this script at a given time via an ical event.

then, later, i want to stop the same script at a certain time,
again via an ical event.

thanks :slight_smile:


I recommend to run the script via an iCal event and quit it in code

for example

	if time of (current date) ≥ 18 * hours then exit repeat
end repeat

so what would be the code for

if time is 16:00
tell keynote to quit

thanks :slight_smile:

if time of (current date) ≥ 16 * hours then quit application "Keynote"

and you have to abort the script with return or error number -128 (user cancelled)

and what if it were 13:03 ?

thanks :slight_smile:

13 * hours + 3 * minutes

the time portion of current date represents the number of seconds since midnight
hours and minutes are constants (3600 and 60)

thanks alot :slight_smile:


You have an interesting idea. This might work with a reopen handler:

on run
	-- initialize
end run

on reopen
end reopen

on idle
	-- your stuff here
	beep 1
	-- idle for 3 seconds
	return 3
end idle

You need to save this as a stay open application. I haven’t tested it with Calendar yet. Hope it works.


Model: MBP
AppleScript: AS 2.2.4
Browser: Safari 536.28.10
Operating System: Mac OS X (10.8)

I was thinking that you could use this as an alarm that stays on for a certain amount of minutes. Like a reverse snooze. The alarm should be duplicated when you hit the snooze button.