• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
0

Indesign Server : Repeat action i every 10 seconds

Community Beginner ,
Jun 23, 2021 Jun 23, 2021

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.

TOPICS
Scripting

Views

338

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

People's Champ , Jun 25, 2021 Jun 25, 2021

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'

...

Votes

Translate

Translate
Community Expert , Jun 29, 2021 Jun 29, 2021

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

Votes

Translate

Translate
People's Champ ,
Jun 25, 2021 Jun 25, 2021

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 29, 2021 Jun 29, 2021

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.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 29, 2021 Jun 29, 2021

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 30, 2021 Jun 30, 2021

Copy link to clipboard

Copied

LATEST

Thank you so much Manan ! It works like a charm !

By.

Vincent.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines