This is the format of my stay open «On Idle» handler
on idle
set MaxInactiveTime to 2 * minutes
set InactiveTime to 0
set idleTime to 0
set NoActivTime to 0
set vActiv to 0
set vChange to 0
tell application "System Events"
---Main script is here
return 15
end tell
end idle
Why does the «return» statement restart at the beginning of the «On Idle» handler, rather than at the «tell» statement ? I thought that because the «Return» was located just before the «end tell» statement it would start over at the «tell» statement.
How do I define/initialize my variables without resetting them at each «return» ?
I am often using code like follows to solve this problem:
property something : "Foooooo"
property idleactive : false
on run
set idleactive to false
set something to "foooooo"
set idleactive to true
idle {}
end run
on idle
if idleactive is true then
display dialog something
end if
return 1
end idle
But I am also anxious to see the solutions of our scripting fellows
Your solution is perfect, Martin,
merely the idle{} line is not necessary, because the idle handler will be called immediately after the run handler anyway,
if there is nothing else