Copy link to clipboard
Copied
I've done a lot of research and even found this question asked on another website, but no answers have been found. Has anyone been able to create a non-blocking timer? Something not involving $.sleep(), as that is blocking. I've tried app.scheduleTask(), but had issues with it not seeing any of my objects or variables when it runs within a dockable script. Perhaps I'm misunderstanding the use of it, but maybe someone can shed some light on it. The base goal is to have a progress bar update, but not via a loop of any kind. I am checking a system folder for files and as the folder gets more files I want the progress bar to update accordingly. A simple function is being used and just needs to be launched on an interval basis to process the folder. Appreciate any help.
With app.scheduleTask(), you need to be sure that your variable within its scope - generaly if your variable is inside a function, it might be outside of the scope as the variable might not exist anymore.
Also, the app.scheduleTask() will stop working whenever an after effects window pop up, eg. alert window, open window, preferences window...
The only way we were able to have a task being scheduled and still working with those window was with a flash object, the timer inside it was calling intera
...Copy link to clipboard
Copied
With app.scheduleTask(), you need to be sure that your variable within its scope - generaly if your variable is inside a function, it might be outside of the scope as the variable might not exist anymore.
Also, the app.scheduleTask() will stop working whenever an after effects window pop up, eg. alert window, open window, preferences window...
The only way we were able to have a task being scheduled and still working with those window was with a flash object, the timer inside it was calling interacting with extendscript using the invokePlayerFunction and externalInterface.call() functions. However, flash support in CC seems discontinued, so it is not working anymore.
Copy link to clipboard
Copied
With app.scheduleTask(), you need to be sure that your variable within its scope - generaly if your variable is inside a function, it might be outside of the scope as the variable might not exist anymore.
Also, the app.scheduleTask() will stop working whenever an after effects window pop up, eg. alert window, open window, preferences window...
Exactly the issues I was coming across.
Time to file a feature request it sounds like.
Copy link to clipboard
Copied
I have a script that checks every second if a project has been opened in AE and then clears the interval once one has. I used to run into problems with this in CC 2014 if I did File Open (getting the script cannot execute while modal window is expecting a response error), so I had to use Open Recent or always double-click a file. (Also, trying beginSuppressDialog() and endSuppressDialog(false) didn't work).
This seems to have been resolved in CC 2015. Just curious if anyone figured out a way to get around it in CC 2014 since some of the people where I work still use that?
Copy link to clipboard
Copied
Maybe you can try using an HTML5 panel instead of a traditional script? Not sure whether the timer functions are more robust there, but maybe worth a try.
Copy link to clipboard
Copied
thanks, I should have mentioned that I am using a HTML5 panel and angular that loads in stored project data from a database when it detects a file has been opened and matches the file name to a database that stores that project's data. Everything works except that annoying script error in CC 2014.
Copy link to clipboard
Copied
And it does not make a difference whether you use the app.scheduleTask() from ExtendScript or a timer from the jacascript/HTML5 part of the app?
Copy link to clipboard
Copied
I had not tried the scheduleTask approach. I will give it a shot. Thanks!
Copy link to clipboard
Copied
I found this to be useful. It's from the Illustrator Scripting forum. Those guys are mad talented! Check out Matthias Guntrum's answer at the bottom. It gave me a good place to start. It's "non-blocking" while the function it executes is not running, but for all practical purposes, it does block the user from doing things.
Anything similar to javascript's setInterval in ExtendScript?
—Arie
Copy link to clipboard
Copied
Thanks. I will try that out as well
Copy link to clipboard
Copied
I know you are still using 2014, but they did add these to CC 2015 finally and they appear to be non-blocking.
app.setTimeout()
app.cancelTimeout()
Copy link to clipboard
Copied
Sweet! Thanks, David!
I had no idea, thank you for letting me know. Can you point me to the latest scripting docs / notes?
Copy link to clipboard
Copied
This is where the latest docs usually end up. http://www.adobe.com/devnet/aftereffects.html‌ , but since there is no new doc for 2015, I just used my ExtendScript Developer Utility script to view the methods and properties that are available.
You can also just use the reflection object in ExtendScript as well.
app.reflect.methods
app.reflect.properties
That'll tell you what is in there for the app object. Just watch yourself though, you can definitely launch things you shouldn't, break things you don't want to, and deactivate the app if not careful.
Copy link to clipboard
Copied
Thanks, David and Arie. Yes, we noticed that as of CC 2015, even the setInterval and clearInterval methods on the angular side of our app started working, but we were trying to retro-engineer for users who still used CC 2014. Luckily, yesterday I was told we no longer have to do that.
Thanks for you help, everyone. If/when I have time, just for fun, I am still going to see if I can come up with some kind of non-blocking solution for 2014 using the scheduleTask methods.
Copy link to clipboard
Copied
If/when I have time, just for fun, I am still going to see if I can come up with some kind of non-blocking solution for 2014 using the scheduleTask methods.
It would be appreciated by all if you do find a viable workaround. Plus having a coding challenge like this is always fun. I know I've been trying for awhile now to figure it out.
Copy link to clipboard
Copied
I will keep you posted. May not be until next week when things calm down a bit but will definitely give it a shot!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now