Re: Is there a "wake up" detector?
Re: Is there a "wake up" detector?
- Subject: Re: Is there a "wake up" detector?
- From: "Marc K. Myers" <email@hidden>
- Date: Wed, 03 Oct 2001 02:30:26 -0400
- Organization: [very little]
The <<event pmgtwake>> worked perfectly! Thank you!
Now to the second part of my original question. What I want to do with
the wakeup detector is trigger an idle handler to run prematurely, that
is before it would normally run based on the return from its last run.
What seems to be happening is that the idle handler gets called and runs
to completion but the number of seconds set in the return is ignored.
Instead, the handler runs again when the originally alloted number of
seconds has run out. Am I interpreting this correctly: an idle handler
can have only one pending return, so if it is run again before that time
is up the new return count will be ignored.
If that's the case, is there any way around it? I was hoping that the
new return count would replace the original one.
property theInterval : ""
global nextStart, firstTime
on run
try
if (keys pressed) contains {"Option"} then
set theInterval to ""
end if
end try
repeat until ((class of theInterval is integer) or (class of
theInterval is real))
set dlgRslt to (display dialog "How many times per hour would
you like " & [optn-L]
"the time to be spoken?" default answer "2" buttons {"OK"}
default button 1)
try
set theNbr to (text returned of dlgRslt) as number
if theNbr is not greater than 0 then
set theNbr to 1
else if theNbr > 240 then
set theNbr to 240
end if
set theInterval to round (hours / theNbr)
end try
end repeat
set rightNow to (current date)
set startTime to date "00:00" of rightNow
set nextStart to ((rightNow - startTime) div theInterval) + 1
set nextStart to startTime + (nextStart * theInterval)
set firstTime to true
end run
on idle
if firstTime then
set firstTime to false
else
if (current date) > (nextStart + 5) then
activate
display dialog "Bypass" giving up after 5
set rightNow to (current date)
set startTime to date "00:00" of rightNow
set nextStart to ((rightNow - startTime) div theInterval) + 1
set nextStart to startTime + (nextStart * theInterval)
else
set theText to time string of nextStart
set {od, AppleScript's text item delimiters} to [optn-L]
{AppleScript's text item delimiters, {":00"}}
set theText to (text items of theText)
set AppleScript's text item delimiters to od
set theText to (theText as text)
if text -2 thru -1 of theText is "AM" then
set newText to "ay em"
else
set newText to "pee em"
end if
set theText to ((characters 1 thru -3 of theText) & newText)
say "It is now " & theText using "Ralph"
set nextStart to nextStart + theInterval
end if
end if
activate
display dialog (nextStart as text) & return & [optn-L]
(nextStart - (current date)) as text giving up after 5
return (nextStart - (current date))
end idle
on [dbl-"<"]event pmgtwake[dbl-">"]
set nextStart to (current date) - 60
tell me to idle
end [dbl-"<"]event pmgtwake[dbl-">"]
NB: the bracketed replacements for the characters our listserver won't display
Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074
[10/3/01 2:20:15 AM]