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

Photoshop interval function in scripting

Community Beginner ,
Jun 29, 2021 Jun 29, 2021

Copy link to clipboard

Copied

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?
TOPICS
Actions and scripting

Views

654

Translate

Translate

Report

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

Community Expert , Jun 29, 2021 Jun 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 t

...

Votes

Translate

Translate
Adobe
Community Expert ,
Jun 29, 2021 Jun 29, 2021

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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
Community Beginner ,
Jun 29, 2021 Jun 29, 2021

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
Community Expert ,
Jun 29, 2021 Jun 29, 2021

Copy link to clipboard

Copied

Done! A new unthreaded reply added...

Votes

Translate

Translate

Report

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
Community Expert ,
Jun 29, 2021 Jun 29, 2021

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
Community Beginner ,
Jun 29, 2021 Jun 29, 2021

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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
Community Expert ,
Jun 29, 2021 Jun 29, 2021

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
Contributor ,
Jun 29, 2021 Jun 29, 2021

Copy link to clipboard

Copied

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)

Votes

Translate

Translate

Report

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
LEGEND ,
Jun 29, 2021 Jun 29, 2021

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
Community Expert ,
Jun 29, 2021 Jun 29, 2021

Copy link to clipboard

Copied

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();  
};

 

 

 

 

Votes

Translate

Translate

Report

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
Community Expert ,
Jul 05, 2021 Jul 05, 2021

Copy link to clipboard

Copied

@Francois Kruger 

 

Where did you end up on this?

Votes

Translate

Translate

Report

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
Community Expert ,
Jul 09, 2021 Jul 09, 2021

Copy link to clipboard

Copied

LATEST

@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.

Votes

Translate

Translate

Report

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