Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Indesign Server : Repeat action i every 10 seconds

New Here ,
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, Server developers

Views

138

Likes

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

Adobe Community Professional , 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'...

Likes

Translate

Translate
Adobe Community Professional , 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

Likes

Translate

Translate
Adobe Community Professional ,
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

Likes

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
New Here ,
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.

 

Likes

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
Adobe Community Professional ,
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

Likes

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
New Here ,
Jun 30, 2021 Jun 30, 2021

Copy link to clipboard

Copied

LATEST

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

By.

Vincent.

Likes

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