Copy link to clipboard
Copied
Hi,
I am testing the onIdle event listener. And it seems like inDesign is Idle all the time, because even if I make new frames and move them around in the document, the event is running every fifth second with this script. Am i doing something wrong, or do i misunderstand the idling concept in InDesign?
I expect the script to run if I have stopped working with the document in 5 second.
tell application id "com.adobe.indesign"
set myIdleTask to make idle task with properties {name:"myIdleTask", sleep:5000}
tell myIdleTask
set onIdleEventListener to make event listener with properties {event type:"onIdle", handler:my IdleEvent}
end tell
end tell
on IdleEvent()
beep
end IdleEvent
Copy link to clipboard
Copied
The behaviour your describe is consistent with an idle event which monitors InDesign idleness. Once the event listener is thrown and as long as no manual operations are done, the timer resets to 0 and starts counting.
If you had a script that would create a frame on such an event and given you don't touch indesign , it will do for ever every 5 seconds.
If you need to stop it after first execution, you need to set its sleep delay to 0 or remove the listener.
Copy link to clipboard
Copied
Actually my goal later is to set Indesign to export JPG-files of all the pages in a document when I'm not working with InDesign (lets say idling for 10 minutes). When I tried this script it does the script every 5 sec even if I'm am working (manually) in Indesign. What conditions makes InDesign in idle mode if making new elements and move them around on the page does not?
Copy link to clipboard
Copied
Actually the confusion was shared. Looking at the doc a second time:
InDesign’s idle tasks execute when there are no events in the event queue for the application to process. It
is easy to run idle tasks by scripting. The onIdle event provides a way to run scripting-based idle tasks. It
can be used to automatically execute a script when InDesign/InCopy is idle. Its event target is IdleTask,
and its event object is IdleEvent.
The sleep property of the idle task is the amount of time that elapses before InDesign calls the task again.
It should be obvious that you need to set the sleep time to a value high enough that it does not interfere
with your work, though this value will vary depending on what tasks the script performs.
Actually, I think it's not what you do or don't inside indesign but there is nothing to proceed as stated in the very first line.
Copy link to clipboard
Copied
So, if I understand this correct - the sleep property just tells indesign to delay 5 sec before running the script, rather than run the script only if the application has been idling in 5 sec?
Copy link to clipboard
Copied
No I don't think so. What i understand myself is that as soon every events have been processed, the delays starts counting. If an external event occurs in the meanwhile, the counter resets. Your listener may not have been fired then. If no events occur, the delay may reach its end and fire your listener. So the counter resets and etc.
But it's mostly all I can tell about this topic. Every time I used idleEvents, I used it with small delays and I wanted them not to be ceased.