Applescript单击“保存”按钮

时间:2013-10-30 16:30:33

标签: applescript

我得到了错误;无法获得进程“TextEdit”的按钮“保存”。

 activate application "TextEdit"
 tell application "System Events" to tell process "TextEdit"
 keystroke "s" using {command down}
 click button "save"
 end tell

我也想要包括像“窗口1”一样,但我仍然无法正常工作。任何帮助都感激不尽。感谢

1 个答案:

答案 0 :(得分:2)

为什么不直接与应用程序对话?

tell application "TextEdit"
    tell document 1 to save
end tell

如果你必须使用GUI,你需要正确的层次结构(但最好直接与应用程序对话)

activate application "TextEdit"
tell application "System Events"
    tell process "TextEdit"
        keystroke "s" using {command down}
        delay 1
        click button "Save" of sheet 1 of window 1
    end tell
end tell