AppleScript引号问题排查:为何出现语法错误?
AppleScript语法错误解决:Finder选中文件用QuickTime Player打开
你的代码里的语法错误核心出在open theFile with application "QuickTime Player"这一行——Finder的open命令不支持with application这种写法,这才是触发语法报错的主要原因。另外如果遇到引号相关提示,检查是否不小心用了中文全角引号(“”),AppleScript只认英文半角引号("")。
给你两种可行的修正方案:
方案1:直接调用QuickTime Player打开选中文件
tell application "QuickTime Player" open (selection of application "Finder") end tell
方案2:通过Finder指定应用打开(使用正确的参数)
tell application "Finder" set theFile to selection open theFile using application file id "com.apple.QuickTimePlayerX" end tell
注:用应用ID(com.apple.QuickTimePlayerX)比应用名称更稳定,避免系统语言差异导致的识别问题
内容的提问来源于stack exchange,提问作者HNT
相关产品推荐
相关产品推荐

