Domanda

I'm trying to automate opening and saving a file in applescript. I can't seem to get consistent results with the save dialog though. Is it possible to change a save dialog to a specific folder in applescript?

È stato utile?

Soluzione

This might help you navigate to a folder once the save dialog is raised:

set the clipboard to "/path/to/your/folder"

tell application "System Events" to tell process "SketchUp" -- I'm guessing on SketchUp name
    keystroke "G" using {command down, shift down}
    delay 1
    keystroke "v" using {command down}
    delay 1
    keystroke return
    delay 1
    keystroke return
    delay 1
end tell

Altri suggerimenti

You can do it and keep your clipboard intact, I think. If your save dialog is in TextEdit, if you last saved something to the desktop, for example, the following would change your destination back to Documents. It's easier just to use +D for that, of course, but you can use substitute pretty much whatever path you need. If you have a path with a folder having non-AppleScript allowable characters in the path (such as quotes), you can escape each with the backslash ("\") character.

tell application "TextEdit"
    activate
    try
        tell application "System Events"
            keystroke "g" using {shift down, command down}
            do shell script "sleep 0.2"
            keystroke "~/Documents"
            do shell script "sleep 0.2"
            keystroke return
        end tell
    end try
end tell
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top