Is there an equivalent of setTimeout in Adobe's ExtendScript

adobe, adobe-indesign, extendscript, settimeout

Solution

It's part of the extendscript's `$` object.

$.sleep(1000) //tell extendscript to sleep 1000 milliseconds

Not the same as setTimeout() but you should be able to make it work for you.

EDIT: Here is setTimeout extension for extendscript:

$.setTimeout = function(func, time) {
        $.sleep(time);
        func();
};

$.setTimeout(function () {alert("hello world")}, 3000);

Problem

Javascript's `setTimeout` function is a method of the `window` object. This object doesn't exist in ExtendScript and is therefore not available to scripts made for Adobe InDesign or Illustrator. What can I use instead to acheive the same results?

Original source