Applescript 无法获取列表

Applescript can't get list

所以我希望这个 repeat with 循环打开列表 listOfApplications 中的所有应用程序。我将此代码基于存储在 /Library/Scripts/Script Editor Scripts/Iterate Items/ 的多个脚本。但是 Applescript 给了我错误信息:Can’t get list {\"Google Chrome\", \"Safari\", \"TextEdit\"}." number -1728 from list {"Google Chrome", "Safari", "TextEdit"}。我不知道为什么,我们将不胜感激。

set listOfApplications to {"Google Chrome", "Safari", "TextEdit"}
set applicationsToOpen to every item of list listOfApplications
repeat with i from 1 to the count of applicationsToOpen
    tell application (item i of listOfItems) to launch
end repeat

不要把事情复杂化...下面的 example AppleScript code 将做你想做的事:

set listOfApplications to {"Google Chrome", "Safari", "TextEdit"}

repeat with appName in listOfApplications
    tell application appName to launch
end repeat

注意:示例 AppleScript code 就是这样,没有包含任何 错误处理 不包含任何额外的 错误处理 可能是适当的。用户有责任根据需要或需要添加任何 错误处理 。查看 try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay 命令 在适当的事件之间可能是必要的,例如delay 0.5,适当设置延迟