Applescript command that navigates to a specific folder when the attachments popup appears in safari?

StackOverflow https://stackoverflow.com/questions/23413969

  •  13-07-2023
  •  | 
  •  

Question

I'm building an Applescript that will attach specific files when the attachment prompt appears in Safari.

I initially tried do shell script "open /Users/ea/Desktop/Guru/Deliverables/" but that just opens a new finder window. I need to know how to navigate to the correct folder once the prompt appears (see image below).

I'm sure it's simple, but I'm brand new to Applescript.

enter image description here

Was it helpful?

Solution

The GUI script solution would be:

tell application "System Events" to tell process "Safari"
    tell window 1 to tell sheet 1
        key code 5 using {shift down, command down} --shortcut for go to folder
        tell sheet 1
            set value of text field 1 to <POSIX path to targetfolder as text>
            click button 1
        end tell
    end tell
end tell
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top