‘on idle’ never seems to work for me. I’ve “borrowed” some code from this site and things like the icon move app dont work if I use the ‘on idle’
What is idle? How do I make sumthin idle or not? How long does it have to be idle before the rest of the code starts? And most importantly, how can I become the American Idle?
Can anyone x-plain how idle works, or doesnt work…
well, you make the ‘on idle’ statements, etc., and then you just save them as an app (make sure you pick ‘stay open’) that’s it. i’m not sure what you want to know, so if that wasn’t a very good explanation for what you want, just IM me (sn:swwarmuth)
An ‘idle’ handler contains code that’s to be executed periodically by a stay-open script (ie. a script that’s saved as a stay-open application). When the script first runs, it executes any code at the beginning then runs straight into the idle handler. At the end, the handler should return a number, which tells the system how many seconds to wait before running it again. The script, of course, doesn’t quit, but hangs around for these periodic calls to its idle handler by the operating system.
-- Any preliminary code here
on idle
-- Some action to be executed periodically here
return 60 -- tell the operating system to run the idle handler again in 60 seconds' time
end idle
You may be confusing ‘idle’ with ‘delay’, which is a pause instruction.
As a UK idol, I’m afraid I’m not qualified to answer that.
here’s a simple x-ample of what I thin idle should do, but doesn’t…
on idle
display dialog "I'm idling."
return 5
end idle
now, from what I gather, this should display a dialog (Im idling) every 5 seconds when saved as a stay open application. Well, to put it simply, it doesn’t. The app sits there and does nothing, ever. :?: :? :?:
When saved as a stay-open application - and of course run as an application - your example script should display the dialog until you click one of the buttons. Five seconds after that, the dialog should appear again. It works fine for me, though the dialog might not be visible if another application’s frontmost. (Dialogs are displayed by the application told to display them, in this case the script application itself.)
Also, if you run the script in the Script Editor, then nothing will happen. Script Editor just “sees” the idle handler as a subroutine. You need to run the stay open script app itself.
there is VERY little chance that it is the editor’s fault. are you SURE that you are NOT running the script in script editor after you save it as an app?