Copy link to clipboard
Copied
I did a search for this. I know JavaScript has a built in method for timeouts in the form setTimeout() and clearTimeout(). The only thing I found on this for Photoshop is for Applescript. Is there a way to start a timeout in Photoshop using JavaScript?
I have a script that runs whenever I open a CR2 file but only if I haven't processed it yet (there is a .psd file of the same name). I would like to add in a timeout with a dialog so I can suppress the actions that run from the script but if I do nothing for a specified time (5 seconds) it will default to doing the action.
This is what I have....
var im=app.activeDocument
var f=new String(im.fullName)
var len=f.length-4
var ps=File(f.substring(0,len)+".psd")
if ((im.name.indexOf(".CR2",0)) && (!ps.created)) {
// timeOut=setTimeout("doAction('Sharpen', 'Workflow')",5000)
if (!confirm("Suspend Sharpen?")) {
doAction('Sharpen', 'Workflow')
}
else {
// clearTimeout(timeOut)
}
}
I modified it slightly from my original post. The above reflects the script as I have it now.
I tried setTimeout, settimeout, im.setTimeout, im.settimeout, app.setTimeout, app.settimeout but none are recognized as methods.
Any help is greatly appreciated. Thanks.
Mike
Scripts in Photoshop do not work that way. You can use $.sleep() to set a delay in your script but you will not be able to do anything in Photoshop while the script is running.
You might be able to use Bridgetalk to check the historyState after a delay and run the action then if the state is the same but I have not tried that so it may not work.
Copy link to clipboard
Copied
Scripts in Photoshop do not work that way. You can use $.sleep() to set a delay in your script but you will not be able to do anything in Photoshop while the script is running.
You might be able to use Bridgetalk to check the historyState after a delay and run the action then if the state is the same but I have not tried that so it may not work.
Copy link to clipboard
Copied
Thank you, Michael. This is what I feared, but I guess I'll have to live with it.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now