Copy link to clipboard
Copied
Hello,
For our project we have to scann a directory located on the same machine that the Indesign server.
For this we have this script "scan.js" that we launch once the Indesign server is on :
scan.js :
var cycle=1;
while (1<=1)
{
app.consoleout('Cycle ('+cycle+') de generation lance...');
generate('auto',tabParameters);
sleep(20000);
cycle++;
}
generate() is the function which scann the directory...
The problem is that it seems to consume a lot of energy when we consult the task manager on windows...
My question is :
Is there a way with Indesign server to launch a .js script every 20 seconds without this "tricky" method ?
Thks for your help.
I'm presuming there's a good reason why you don't trigger InDesign Server when the directory in question changes, rather than getting IDS to do this.
Anyway, have a look at application.idleTasks.add()
This will add an idle task to the server. One of its parameters is sleep:
"Amount of time to sleep (in milliseconds) before calling this task again. Setting this to zero will cause task to be deleted."
That sounds like it should consume less resources than the method you're using, although I haven'
...Hi @Vincent42,
Seems you are missing the targetengine statement due to which the event handler is not persisted and hence not called. Just add at the following line at the top of your script and then test
#targetengine test
-Manan
Copy link to clipboard
Copied
I'm presuming there's a good reason why you don't trigger InDesign Server when the directory in question changes, rather than getting IDS to do this.
Anyway, have a look at application.idleTasks.add()
This will add an idle task to the server. One of its parameters is sleep:
"Amount of time to sleep (in milliseconds) before calling this task again. Setting this to zero will cause task to be deleted."
That sounds like it should consume less resources than the method you're using, although I haven't tried it myself. Interested to know if you find that it is so.
HTH,
Ariel
Copy link to clipboard
Copied
Hello Taw,
Thks for your answer !
I think you are right but I can test it. I tried to make work this code on an Indesign and Indesign server but it does'nt work :
var myIdleTask = app.idleTasks.add({name: 'my_idle_task',sleep: 1000});
var onIdleEventListener = myIdleTask.addEventListener(IdleEvent.ON_IDLE, onIdleEventHandler, false);
function onIdleEventHandler(myIdleEvent)
{
alert('taskLaunched !');
}
The event is never trigged ! So the alert "taskLaunched" is never displayed... Would you have any explanations ?
Thks a lot.
Vincent.
Copy link to clipboard
Copied
Hi @Vincent42,
Seems you are missing the targetengine statement due to which the event handler is not persisted and hence not called. Just add at the following line at the top of your script and then test
#targetengine test
-Manan
Copy link to clipboard
Copied
Thank you so much Manan ! It works like a charm !
By.
Vincent.