You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用AppleScript为Adobe InDesign Place Gun加载本地图片?

解决InDesign AppleScript加载Place Gun的路径问题

问题根源

InDesign的load place gun命令不支持直接传入POSIX字符串路径,必须使用AppleScript原生的file或alias对象——这和你接触的其他InDesign/Photoshop命令不同,它们大多兼容POSIX路径,但Place Gun的API设计有特殊要求。

修正方案1:单文件直接加载

将POSIX路径转换为AppleScript alias对象后传入:

on run
    set filePath to POSIX file "/Users/michael/Desktop/BCC_portfolio.jpg" as alias
    tell application id "com.adobe.indesign"
        activate
        load place gun filePath
    end tell
end run

修正方案2:多文件循环加载(适配你的第二个脚本)

需要注意两个关键点:

  1. 把路径字符串转为alias对象,且要放在列表中(循环需要遍历列表元素)
  2. 确保active document已存在(否则会报错)

修正后的脚本:

set loadFiles to {POSIX file "/Users/michael/Desktop/BCC_portfolio.jpg" as alias}

tell application id "com.adobe.indesign"
    activate
    -- 先确保有打开的文档
    if (count documents) = 0 then make document
    tell active document
        if loaded of place gun 1 is false then
            tell place gun 1
                repeat with loadFile in loadFiles
                    load place gun loadFile without showing options
                end repeat
            end tell
        end if
    end tell
end tell

关键说明

  • choose file命令返回的本身就是alias对象,所以你之前用它的版本能正常运行
  • 转换POSIX路径为AppleScript文件对象的通用写法:POSIX file "你的POSIX路径" as alias

内容的提问来源于stack exchange,提问作者Michael Edwards

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 09:35:04