我编写了这个 AppleScript 以通过从列表对话框中选择从“最近的项目”子菜单中打开选定的项目。它适用于第一个项目,然后优雅地退出,而无需继续打开其他项目。
您将在下面看到,我添加了一些“显示对话框”来让我了解它是否应该工作,并且一切都表明它应该工作。尽管如此,它还是不...
tell application "Finder"
activate
try
tell application "System Events"
tell process "Finder"
tell menu "Recent Items" of menu item "Recent Items" of menu 1 of menu bar 1
set menuItemNames to (get name of (every menu item whose position ≠ missing value and name ≠ "Applications" and name ≠ "Documents" and name ≠ "Servers" and name ≠ missing value))
set text item delimiters of AppleScript to ","
set targetMenuItems to (choose from list menuItemNames with prompt "Choose a recent document to view:" with title "Recent Documents" OK button name "Open" with multiple selections allowed) as list
set targetMenuItems to (text items of targetMenuItems as text)
if targetMenuItems ≠ "false" then
set menuitemCount to (count text items in targetMenuItems)
display dialog menuitemCount
display dialog (text item 1 of targetMenuItems)
set x to 1
repeat menuitemCount times
set targetItem to (text item x of targetMenuItems)
display dialog targetItem
click menu item targetItem
set x to x + 1
end repeat
end if
end tell
end tell
end tell
on error errorMsg
display dialog errorMsg
end try
end tell