Skip to main content
Zhiqing_Li
Known Participant
October 24, 2012
Question

scheduleTask() doesn't work !

  • October 24, 2012
  • 3 replies
  • 2194 views

Hi guys,

I was tring to write a function that can repeatly run itself once per second,and I used app.scheduleTask().

like this,

function newFunction () {

     ......

     ......

     scheduleTask("newFunction ()",1000,false);

}

Sometimes it worked, sometimes it didn't work.

Is there something about scheduleTask() that I don't know ?

Or, could you guys tell me how to write a function that can diaplay a number that increase 1 per second on a scriptUI panel ?

Thank you!!!!!

This topic has been closed for replies.

3 replies

Zhiqing_Li
Known Participant
November 2, 2012

I found out that if scheduleTask() doesn't work, you can use

$.sleep(1000);

eval(string);

instead.

Alan_AEDScripts
Inspiring
November 2, 2012

Thanks a lot - will try out and see how it affects general workflow in AFX.

Have ye noticed a background thread running like this causes havoc with working away in AFX? Don't want to get into it if it's problematic.

I am using an 'update' button at the moment - but it would be nice if the script could pick up the changes automatically.

Cheers.

Alan_AEDScripts
Inspiring
March 22, 2016

Know this is quite an old thread but came back to this and not having any issues using scheduleTask....

The most important thing is that it is a string and not code, so that it responds to the "eval" that Adobe calls each iteration.

The modal dialogs seem to pause the running but then it resumes when  a dialog closes, that makes sense.

I came across some code behind the ESTK that uses the scheduleTask in quite an advanced way... an ESTK version but

same principals apply - probably quite similar.

Inspiring
October 25, 2012

Make sure the code your are feeding in the scheduletask is perfectly written. No syntax error, semi-colon at the end of every line of code.

Think of it as if there is no carriage return in you code, it still should execute.

function notWorking(){

          var a = "test"

          var b = anotherFunction()

}

will give :

function notWorking(){var a = "test"var b=anotherFunction()}

SO PUT SEMICOLONS!

function working(){

          var a = "test";

          var b = anotherFunction();

}

will give :

function working(){var a = "test";var b=anotherFunction();}

Alan_AEDScripts
Inspiring
October 26, 2012

Seeing we are on this-

I was wondering if there was a more elegant way of: 'Checking to see if the user has changed the open project'.

Currently the only way I think is to schedule a task that checks every 5 seconds. I need it checked automatically, so I don't want to use an update button etc.

Am I stuck with running tasks repeatedly?

Inspiring
October 26, 2012

Don't go that route, a scheduled task running in background will just break whenever you open a window - e.g. Composition settings.

Inspiring
October 24, 2012

not sure if this is it, but the dosc say to give the scheduleTask() function a string of javascript, where you are supplying a function (which seems like the better way but maybe thats the problem).

Mike Cardeiro

Editor/Animator/Compositor                

D4 Creative Group - Philadelphia, PA       

http://www.michaelcardeiro.com/resume/

http://www.youtube.com/user/mcardeiro

Alan_AEDScripts
Inspiring
October 25, 2012

On Aeenhancers I've seen it's better to:

var theStr = "the javascript code etc";

scheduleTask(theStr,1000,false);