I'm idling at 20,000 rpm - and nothin.

‘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? :wink:

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. :wink:

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.


I knew all this and I am running the script as a stay open app, but still I get nothing. Maybe it’s not my fault, sumthin to do with the editor…

To make sure your idle handler runs, let it beep as a first action:

on idle
-- other actions
end idle

it should beep every 12 secs by default.

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?


Nigal Garvey wrote:

return 60 – tell the operating system to run the idle handler again in 60 seconds’ time

I could be wrong but I thought that was 60ths of a second as in 60 being 1 second and 3600 being 60 seconds? Am I wrong about that?

According to apple’s documentation



It’s a good idea to return a value anyway, otherwise the result of the handler will be the result of the last action carried out in it.