0

我正在尝试在 applescript 中自动打开和保存文件。不过,我似乎无法通过保存对话框获得一致的结果。是否可以将保存对话框更改为 applescript 中的特定文件夹?

4

2 回答 2

0

一旦出现保存对话框,这可能会帮助您导航到文件夹:

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
于 2012-11-16T18:06:26.210 回答
0

我认为,您可以做到并保持剪贴板完好无损。例如,如果您的保存对话框在 TextEdit 中,如果您上次将某些内容保存到桌面,则以下内容会将您的目标更改回 Documents。使用起来更容易⌘</kbd>+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
于 2017-06-13T07:23:43.213 回答