• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Time
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Time


  • Subject: Re: Time
  • From: "Marc K. Myers" <email@hidden>
  • Date: Thu, 27 Sep 2001 19:06:31 -0400
  • Organization: [very little]

> Date: Thu, 27 Sep 2001 12:54:52 +0100
> Subject: Time
> From: david atyahoo <email@hidden>
> To: AppleScript Users <email@hidden>
>
> Hi all
>
> You know the story "new(ish) to AppleScript"
>
> If I want something to happen at a specific time e.g. 9:30pm what would the
> code be.

The easiest approach is to use iDo Script Scheduler. But if you want to
do it strictly within a script the best way is to make the script
stay-open and use an idle handler set to return at the given time. The
problems with this approach are that the clock stops if you put your
machine to sleep and the script quits if you shutdown or restart.

global firstTime

on run
set firstTime to true
end run

on idle
if firstTime
set firstTime to false
set theTime to "9:30 PM"
set theTime to date theTime
if (current date) > theTime then
set theTime to theTime + (1 * days)
end if
return (theTime - (current date))
else
-- do your script stuff
error number -128
end if
end idle

Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074

[9/27/01 7:05:35 PM]


  • Prev by Date: Re: Illustrator 9 Duplicate Command
  • Next by Date: Re: Hacking the Mac via AppleScript
  • Previous by thread: Re: Time
  • Next by thread: "Accepts high-level events" bust in Finder?
  • Index(es):
    • Date
    • Thread