Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Timeouts in JavaScript for PS

Engaged ,
Jun 26, 2009 Jun 26, 2009

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

TOPICS
Actions and scripting
2.0K
Translate
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 1 Correct answer

Guru , Jun 26, 2009 Jun 26, 2009

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.

Translate
Adobe
Guru ,
Jun 26, 2009 Jun 26, 2009

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.

Translate
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
Engaged ,
Jul 01, 2009 Jul 01, 2009
LATEST

Thank you, Michael. This is what I feared, but I guess I'll have to live with it.

Translate
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