File Save Dialog issues

I have refined the script mentioned in Counters and my Mega Macro! and it is mostly working really well, but one area is still a bit inconsistent.

When I Export File as a PNG I use the minimised dialog, as it provides a generally more consistent Save result that the larger dialog.

In the script after the Export, I wait for the dialog to appear, paste in the variable <0001>.png into the filename field (which is the default selection in 90% of cases), pause, then save. This is followed by lots of layer manipulation in Photoshop.
This is repeated many hundreds of times.

Every so often it seems like the filename field isn’t selected and (I think) the tag field is, so the script stalls as it tries to save as the filename of the main file (which it must have done earlier as it is now a duplicate)

What I think I need to achieve is to ensure that the filename field is always selected.

Is that best achieved by using a Mouse Click, then Select All.
Or is there a conditional I could use, or another way altogether to guarantee that the filename field is always selected?

Thanks again in advance - all help gratefully received

Hey Richard,

Personally I'd use either UI Browser by PFiddlesoft to discover the name field and use AppleScript UI-Scripting to set it directly.


I'd AppleScript Default Folder to detect when the dialog was open and to set the file name.

Optionally you could use a Click at Found Image action to manage things, but detecting action and effect is not so easy.

I don't have Photoshop, so I can't test, but here's an example script using TextEdit.

  • Open a document.
  • Type some text.
  • Type S
  • Run the script from the Script

It works on Mojave – no guarantees about other versions of macOS.


Oh yes UI Browser might be just the thing - not heard of it before, but it looks perfect.
My AppleScript is non existent but will have a go!
Thanks again!

So I have got to this point:

tell application "System Events"
  tell process "Adobe Photoshop 2021"
    select text field 1 of window "Save"
    select all
  end tell
end tell

Where select text field 1 of window "Save" is the correct field according to UI Browser

But i'm not sure if that is correct (other than it is a valid AppleScript") - and the KBM macro seems to stall on that script.

Given Photoshop 2021 has quite extensive AppleScript support you might be able to do this without having to resort to UI scripting.

You can examine the AppleScript dictionary in either Script Editor or (my preference) Script Debugger.

Apologies if this is off-target but I hope it might help!

1 Like

Hey Richard,

Always test AppleScript in a Script Editor before trying it in Keyboard Maestro, unless the AppleScript is dependent upon running from Keyboard Maestro.

You have more control and better feedback.

When writing and testing AppleScript on macOS I advise folks to use Script Debugger – even if they don't write much AppleScript.

I've used it for 26 years plus and cannot begin to express how much it changed the AppleScript experience for me.

The commercial version is not inexpensive ($99.99), BUT it reverts to its FREE “Lite” version after a 30 day demo period – and the free version still beats the utter pants off of Apple's Script

Try this:

tell application "System Events"
   tell process "Adobe Photoshop 2021"
      set its frontmost to true
      tell text field 1 of window "Save"
         set its value to "SOMETHING TO SAVE!"
      end tell
   end tell
end tell

It should change the save-name in the dialog.

On the other hand – @tiffle idea is a good one.

You might be able to directly export to PNG and avoid the rigamarole.

A good place to ask about that would be here:



I have a long way to go with Apple Script for sure!

I suppose what I’m trying to do is always ensure that the filename text field is always selected - because the KBM script pastes in the Variable generated name.

From observing what’s happening at the start of the script the filename field is selected, then at some point it gets deselected, the script pastes in the Variable generated name (to nowhere) and the file saves with the filename. When it does this the second time the script stops as there is a file replace alert.

I think if I get the AppleScript to work then the script will just work, so it is tantalisingly close :grinning_face_with_smiling_eyes:

But thanks for the pointers, it is all really helpful!

tell application "System Events"
	tell process "Adobe Photoshop 2021"
		select text field 1 of window "Save"
		set focused of text field 1 of window "Save" to true
	end tell
end tell

Seems to potentially be doing what I want!!!!

When opening Photoshop's Dictionary in Script Debugger it doesn't seem to cater for the Quick Export as PNG menu item. But with the various prods provided by the replies I realised in UI Browser you can drill down further into the attributes to make the text field 1 focused, and in Script Editor it seems to do it, so will now try KBM :grinning_face_with_smiling_eyes:

Yes that was useful, but there is a very odd difference (and Photoshop can be very odd) between the
Quick Export as PNG menu and the other Export menus
I'm guessing they haven't put the former in the AppleScript Dictionary, but they have the other ones.
But that is very Adobe :roll_eyes:

1 Like

That’s the link I provided in Post #6...  :sunglasses:

1 Like

Yes - but mine looked nicer :exploding_head: Gone now…


Just for you I prettified it.  :sunglasses:

1 Like

Much better!!

1 Like