Illustrator CC2020 AppleScript置入文件弹出格式选择框无响应问题
Illustrator CC2020 AppleScript Placed Item File Format Popup Issue
我之前也碰到过一模一样的问题!升级到Illustrator CC2020(24.0)之后,原本在CC2019里流畅运行的AppleScript置入代码突然抽风——不仅弹出「Select a File Format to open file:」的选择弹窗,选完三个选项里的任何一个,都没东西被插入进来,折腾了好半天。
问题根源
后来查了下,应该是CC2020对file path参数的解析逻辑做了调整:之前直接传冒号分隔的路径就能正常识别,但新版本对路径格式的要求更严格,或者需要明确指定文件格式才能跳过弹窗。
修复方案
这里有两种亲测有效的解决方法,你可以试试:
方法1:将路径转换为Alias对象
把传入的冒号路径先转成系统原生的alias格式,再传给Illustrator,让它能正确识别文件:
on run argv tell application "Adobe Illustrator" activate set user interaction level to never interact -- 把传入的字符串路径转为alias对象 set targetFile to alias (item 1 of argv) set placedRef to make new placed item in layer "ignore" of current document with properties {file path:targetFile} without dialogs end tell end run
方法2:明确指定文件格式属性
如果转alias的方式没用,可以直接在properties里加上file format参数,告诉Illustrator要处理的文件类型(比如PDF对应Adobe PDF):
on run argv tell application "Adobe Illustrator" activate set user interaction level to never interact -- 明确指定文件格式为PDF set placedRef to make new placed item in layer "ignore" of current document with properties {file path:item 1 of argv, file format:Adobe PDF} without dialogs end tell end run
小提醒
你提供的运行示例命令里路径有个小错误:Download应该是Downloads,修正后再测试会更准确,比如:osascript test.scpt :Users:myusername:Downloads:test.pdf
如果是处理其他格式的文件,对应的file format参数要调整,比如PNG对应PNG,JPG对应JPEG,可以在Illustrator的AppleScript字典里查到完整的格式枚举值。
我自己用方法1解决了这个问题,你两种都试试,应该能搞定弹窗和无法插入的问题!
内容的提问来源于stack exchange,提问作者Bfr
相关产品推荐
相关产品推荐

