Skip to main content
leol30
Known Participant
May 24, 2020
Answered

Using a Script in an Action without seeing a dialog box

  • May 24, 2020
  • 5 replies
  • 2613 views

===================

var doc = activeDocument
doc.resizeCanvas(Math.min(doc.width,doc.height),Math.min(doc.width,doc.height))

===================

I have run the above two line script on individual landscape and portrait photos and it works. It crops the photos to a square using the dimension of the shortest side. No Canvas Size dialog box appears.

 

However, if I integrate the Script into an Action and start a batch of photos the Canvas Resize dialog box appears needing an OK confirmation for each photo.

 

Is there anyway I can stop the Canvas Resize dialog box appearing?

 

Any help would be appreciated. Thanks in advance.

This topic has been closed for replies.
Correct answer Kukurykus

Maybe try with following line at beginning:

 

displayDialogs = DialogModes.NO

 

5 replies

leol30
leol30Author
Known Participant
May 24, 2020

A big "THANK YOU" to everyone. With everyone's help I've got two scripts working in one action so I'm now ready to batch all the photos that need cropping and saving as squares. Cheers everyone.

 

Kukurykus
Legend
May 24, 2020

I marked my answer as correct, as you didn't while I understand that was right solution?

leol30
leol30Author
Known Participant
May 24, 2020

Thanks for the replies. I was getting somewhere using these extra lines:

app.displayDialogs = DialogModes.NO;
var doc = activeDocument
doc.resizeCanvas(Math.min(doc.width,doc.height),Math.min(doc.width,doc.height))
app.displayDialogs = DialogModes.YES;

 

It worked. I had saved the script in an action which I deleted. I then tried to repeat the process but I cannot get the Action to record the script. Have I toggled something on or off that is making the recording of an action behave differently? I noticed there is no tick next to the title of the Action.

c.pfaffenbichler
Community Expert
Community Expert
May 24, 2020

Have you tried »Insert Menu item«? 

leol30
leol30Author
Known Participant
May 24, 2020

I'm not familiar with that command! I can't find it!

c.pfaffenbichler
Community Expert
Community Expert
May 24, 2020

Please post a screenshot of the expanded Action in the Actions Panel. 

Kukurykus
KukurykusCorrect answer
Legend
May 24, 2020

Maybe try with following line at beginning:

 

displayDialogs = DialogModes.NO

 

leol30
leol30Author
Known Participant
May 24, 2020

Thanks, I used a simlar line and it worked but I now have another problem recording the script in the Action.

JJMack
Community Expert
Community Expert
May 24, 2020

I had no problem and had no dialog.  I created a one step action and batched it via Image Processor Pro.  I'm sure Adobe's script Image Processor could also be used.  I find these Script are more flexible than Automate Batch.  I may use that it I want to replace the source images with square replacements. I tend not to batch replace image files.

 

JJMack
leol30
leol30Author
Known Participant
May 24, 2020

Thanks JJMack. I don't have Image Processor Pro. The Image Processor looks like it should work. However, I prefer to highlight files in Bridge and then run Tools > Photoshop > Batch. If I can't save a script in an Action I will have to try the Image Processor.

JJMack
Community Expert
Community Expert
May 24, 2020

Whay doe you perfer to iset  Bridge menu Tools>Photoshop>Batch the when there are also menu intems in that photoshop menu for Image Processor... and Image Processor Pro... as well as Batch...

 

JJMack