Reputation: 4088
Here's my script:
on idle
tell application "Finder" to open the startup disk
return 100
end idle
When I hit compile, it appears to compile. When I hit run, nothing happens. I've made several variants and I get get any to run.
Upvotes: 2
Views: 270
Reputation: 3466
It won’t run from AppleScript Editor, because AppleScript Editor doesn’t idle, so to speak.
One solution, if you need to run it from AppleScript Editor for testing, is to put the meat of the script into a separate handler, and then call that handler from both the idle
and run
handlers;
on openStartup()
tell application "Finder" to open the startup disk
end doMeat
on idle
openStartup()
return 100
end idle
on run
openStartup()
end run
If you don’t need to run it from AppleScript Editor, then just save it as an application. Applications get idle messages, and so it will work from there.
If you need to test multiple iterations of the script in AppleScript Editor, you can fake the idle by just calling the handler twice in your run
handler, with a delay between them:
on run
openStartup()
delay 100
openStartup()
end run
And of course you could also use a loop to repeat multiple times.
Just remember to comment out the test run
handler when you save it as an application.
For simple scripts, I often just replace idle
with run
when I’m testing it, then put run
back to idle
when I save it.
Upvotes: 3