AppleScript打开“Open Recent”文件

时间:2012-08-25 12:06:23

标签: applescript

是否可以使用AppleScript打开最近的文件? 我尝试了以下脚本,但它不起作用。

on run
    try
        tell application "System Events"
            set theApp to (get name of first process whose frontmost is true)
            click menu bar item "Archivio" of menu bar 1 of process theApp
            click menu item "Apri recente" of menu "Archivio" of menu bar item "Archivio" of menu bar 1 of process theApp
            click menu item " test" of menu "Apri recente" of menu item "Apri recente" of menu "Archivio" of menu bar item "Archivio" of menu bar 1 of process theApp
        end tell
    end try
end run

错误是

  

- >错误编号-1728来自«class menI»“test”of«class menE»“Apri recente”of class menI»“Apri recente”of class menE»“Archivio”of class class mbri»“Archivio”of«class mbar »«class prcs»1 AppleScript Editor“

1 个答案:

答案 0 :(得分:1)

当“ Apri recente ”子菜单打开时,这似乎是一个错误。 但这不是必需的,您可以一键完成。

tell application "System Events"
    tell (get first process whose frontmost is true)
        click menu item " test" of menu "Apri recente" of menu item "Apri recente" of menu "Archivio" of menu bar item "Archivio" of menu bar 1
    end tell
end tell