2013-10-30 93 views
0

我得到錯誤;無法獲取進程「TextEdit」的按鈕「保存」。Applescript點擊保存按鈕

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

我還想包括像「窗口1」仍然我無法得到這個工作。任何幫助都感激不盡。謝謝

回答

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 
+0

如果我想點擊菜單項重命名或導出爲PDF然後我需要點擊「保存」按鈕 – kuruvi

+0

您可以另存爲,看字典 – mcgrailm

+0

非常感謝,我可以在哪裏學習「如何在腳本編輯器中使用applescript字典/庫? – kuruvi