• 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: Egg Timer Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Egg Timer Question


  • Subject: Re: Egg Timer Question
  • From: Michael Terry <email@hidden>
  • Date: Fri, 16 Jan 2004 20:37:43 -0800

On Jan 16, 2004, at 4:18 PM, WFT wrote:

I have young students using a recently donated PowerMac running 10.2.8
Jaguar.

Does anyone know of an applescript solution that would substitute for
an egg timer in limiting the time a student uses the Mac? What I have
found
in a all-too-quick glance through Version Tracker are timers for
debates,
tea making, etc - none of which let the user (the student) know that
they
have exceeded a time limit. I would love to find something more, eh,
halting for the running application. Ideas?



Having saved it as a stay-open script application, I've been using the following simple script as an egg timer myself. If you want it to actually quit a particular application also, you could insert a 'tell application "Blah" to quit' statement in the idle handler's 'if' block.

----------------------------------
-- Timer.app
----------------------------------

property alertTime : missing value

on run
display dialog "How many minutes until alert?:" default answer "" with icon note buttons {"Quit", "Set Timer"} default button "Set Timer"
if button returned of result is "Quit" then
tell me to quit
else
try
set my alertTime to text returned of result as number
set my alertTime to (current date) + ((my alertTime) * minutes)
on error
return beep
end try
end if
end run

on idle
if (current date) > my alertTime then
try
tell application (path to frontmost application as Unicode text)
display dialog "Time's up!"
end tell
on error
tell me
display dialog "Time's up!"
end tell
end try
end if
end idle

on getTimeRemaining()
return (alertTime - (current date)) / 60
end getTimeRemaining

----------------------------------

There's the unfortunate drawback that you don't get to see how much time is left. To get around this, I've been using a feature of the system Script Menu. If you place scripts in ~/Library/Scripts/Applications/AppName/, then those scripts are displayed at the bottom of Script Menu when that application is frontmost. So, in this case, I put this little script:

----------------------------------
-- Time Remaining.scpt
----------------------------------

-- To do:
--  display fractions of a minute in seconds

tell application "Timer"
display dialog (getTimeRemaining() as Unicode text)
end tell

----------------------------------

in ~/Library/Scripts/Timer/

Anytime I want to find how much time is left, I just switch to Timer and choose Time Remaining from Script Menu.


Cheers,
Mike
_______________________________________________
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.

  • Follow-Ups:
    • Re: Egg Timer Question
      • From: Michael Terry <email@hidden>
References: 
 >Egg Timer Question (From: WFT <email@hidden>)

  • Prev by Date: Re: Escaped tab character in shell (sed)
  • Next by Date: Piping sed to sed commands
  • Previous by thread: Re: Egg Timer Question
  • Next by thread: Re: Egg Timer Question
  • Index(es):
    • Date
    • Thread