Skip to main content
Participant
June 29, 2021
Answered

Photoshop interval function in scripting

  • June 29, 2021
  • 6 replies
  • 1168 views

I am trying to script something in Photoshop that has to run every X seconds. In JavaScript it would look like this:

 

function run() {
    alert('Ran!')
}
setInterval(run, 1000)
 
But in Photoshop's JavaScript, "setInterval is not a function". Any idea how else I would get any form of interval working?
This topic has been closed for replies.
Correct answer Stephen Marsh

The original post from @SuperMerlin (thank you) can be found here:

 

Reminder to save?

 

Using this script, I was able to create a sort of "Rube Goldberg Machine" or "Heath Robinson Contraption" to auto-save files, with or without a notification. Others may be able to create a more elegant solution:

 

automate save as or export with sequential file names

 

Some other links that may be useful can be found below, some links are to old forum posts that are now broken, but you can copy the name of the topic thread from and paste it into the forum search to overcome the link being broken:

 

Need help making a script for saving as jpg with interval

Automatic Save Function? (NOT for autorecovery)

 

EDIT: Just in case the link to SuperMerlin's script is broken in future forum software changes:

 

 

 

/* 
Reminder to save?
https://forums.adobe.com/message/11013186#11013186
https://community.adobe.com/t5/photoshop/reminder-to-save/m-p/10466042?page=1
*/

#target bridge;  

if( BridgeTalk.appName == "bridge" ) {    
var psRem= new MenuElement( "command", "PS Reminder", "at the end of Tools");  
}  
psRem.onSelect = function () {   
var mins =  60000 * 3; // Three minutes  
psReminder = function(){  
    var bt = new BridgeTalk();  
    bt.target = "photoshop";  
    bt.body = "if(documents.length) alert('Save Reminder!');";   
    bt.send(4)  
    }  
id = app.scheduleTask( "psReminder()", mins, true );   
var win = new Window("palette","Photoshop Reminder");  
win.bu1 = win.add("button",undefined,"Stop Reminder");  
win.bu1.onClick = function(){  
    win.close(0);  
    app.cancelTask (id);  
    }  
win.show();  
};

 

 

 

 

6 replies

Stephen Marsh
Community Expert
Community Expert
July 10, 2021

@Francois Kruger 

 

Please add likes and or correct answers to the various posts so that when others are searching for a resolution to their issue it will be obvious that a solution was found.

Stephen Marsh
Community Expert
Community Expert
July 5, 2021

@Francois Kruger 

 

Where did you end up on this?

Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertCorrect answer
Community Expert
June 29, 2021

The original post from @SuperMerlin (thank you) can be found here:

 

Reminder to save?

 

Using this script, I was able to create a sort of "Rube Goldberg Machine" or "Heath Robinson Contraption" to auto-save files, with or without a notification. Others may be able to create a more elegant solution:

 

automate save as or export with sequential file names

 

Some other links that may be useful can be found below, some links are to old forum posts that are now broken, but you can copy the name of the topic thread from and paste it into the forum search to overcome the link being broken:

 

Need help making a script for saving as jpg with interval

Automatic Save Function? (NOT for autorecovery)

 

EDIT: Just in case the link to SuperMerlin's script is broken in future forum software changes:

 

 

 

/* 
Reminder to save?
https://forums.adobe.com/message/11013186#11013186
https://community.adobe.com/t5/photoshop/reminder-to-save/m-p/10466042?page=1
*/

#target bridge;  

if( BridgeTalk.appName == "bridge" ) {    
var psRem= new MenuElement( "command", "PS Reminder", "at the end of Tools");  
}  
psRem.onSelect = function () {   
var mins =  60000 * 3; // Three minutes  
psReminder = function(){  
    var bt = new BridgeTalk();  
    bt.target = "photoshop";  
    bt.body = "if(documents.length) alert('Save Reminder!');";   
    bt.send(4)  
    }  
id = app.scheduleTask( "psReminder()", mins, true );   
var win = new Window("palette","Photoshop Reminder");  
win.bu1 = win.add("button",undefined,"Stop Reminder");  
win.bu1.onClick = function(){  
    win.close(0);  
    app.cancelTask (id);  
    }  
win.show();  
};

 

 

 

 

Inspiring
June 29, 2021

Yes, you won't get it to work directly (photoshop does not have setInterval) 

But these are some options you could consider:

  • BridgeTalk (targetting Adobe Bridge)
  • Photoshop's Script Events Manager
  • a Photoshop Plugin (CEP or UXP)
  • or Windows 10's task scheduler (thanks Kukurykus)
Kukurykus
Legend
June 29, 2021

Loll, since I can't remember I shared such hint ever can you link a post where I helped you with that 😄

c.pfaffenbichler
Community Expert
Community Expert
June 29, 2021

May one ask what you are trying to achieve with this? 

Participant
June 29, 2021

I'd like to write a script that will export a jpg every 30s or so. To later turn into a timelapse. I got all the exporting code, now I just need to loop it every 30s or whatever. That is where I am stuck at now.

Stephen Marsh
Community Expert
Community Expert
June 29, 2021

This is exactly the sort of thing that the Bridge script that I referred to does! I'll dig up the link for you...

Stephen Marsh
Community Expert
Community Expert
June 29, 2021

Scripts run in Photoshop "lock up" the UI then finish and release the UI.


I believe that you would need to use BridgeTalk and run the script in Adobe Bridge, which would then do something in Photoshop.

 

The code is too advanced for me, but I can post an example.

 

Perhaps an extension panel could do this.

Participant
June 29, 2021

If you could maybe post something where it does alert('hi') every 30s or so, that would be seriously helpful!

Stephen Marsh
Community Expert
Community Expert
June 29, 2021

Done! A new unthreaded reply added...