Scripting a Full Path from Standard Save As… Dialog Box?

Does anyone know how to specify the full path of a file to be saved from the standard file dialog box? All I’ve come up with is a cludge of scripting “SHIFT-CMD-G”, using image recognition to find the light blue background color for the text, and then scripting a right-click-paste. Any ideas? Thank you.

Post your script so we can see what you’re doing.

Thank you for your reply. I’m getting to the macOS save dialog box via another dialog box, but I don’t that matters here. I’ve commented below to hopefully convey what I’m doing. (Forget the image recognition bit.) I’m stuck where a miracle occurs. :sweat_smile: Thank you again.

-- Open the RX's Export dialog box, and the macOS save dialog box.
tell application "System Events”
	tell process "iZotope RX 10”
		-- Choose "Export"; using the item number because title does not work this item.
		click menu item 10 of menu 1 of menu bar item "File" of menu bar 1
		delay 0.1
		-- Click the OK button in the Export dialog box. This produces the standard macOS Save dialog.
		click button 2 of group 1 of group 1 of window 1
		delay 0.1
		-- Press the key shortcut to bring up the macOS path selection floating window.
		keystroke "G" using {command down, shift down}
		-- Set the folder path to "~/Documents/"
		-- [A MIRACLE OCCURS]
		-- Set the file name. Use "Window 1" because there are two windows with the same name as the one we want.
		set fileName to a reference to button 8 of group 2 of group 3 of window 1
		tell fileName
			set focused to true
			set value to "Test File"
		end tell
		delay 0.1
		-- Save the file
		click button "Save" of window 1 
	end tell
end tell

Assuming that it’s specifically the Documents folder that you’re after, from within the save/open dialogues, command-shift-O will set its focus to the Documents folder.

1 Like

That is amazing - thank you so much! And I can see now how to interact with that text field. Cheers!!!

I had no idea - thank you for the tip!

Thank you again for your continued help!

Could you please explain how the path gets in there? (I’m surprised that Apple doesn’t let you paste in a full path into a file dialog box.)

Also, could you please tell me what a "sheet’ is? (Google keeps showing me Numbers scripting.) When I monitored all the windows in UI Browser, I indeed saw a “sheet” at one point in a group. So, I know it’s real… :sweat_smile:

In the context of Numbers, a sheet is a ‘page’ within a Numbers document. You can find out (a little) more via Script Editor - File - Open Dictionary then choose Numbers and search for ‘sheet’.

A typical AppleScript that uses Numbers might be structured something like this:

tell application "Numbers"
	tell document 1
		tell sheet 1
			-- do stuff
		end tell
	end tell
end tell

It doesn’t look as though the term has any meaning when scripting isotope.

Thank you once again - I understand now. :bulb: