Fonts Applescript-返回脚本与应用程序不同的值。。。?

Fonts Applescript-返回脚本与应用程序不同的值。。。?,fonts,applescript,status,Fonts,Applescript,Status,我得到了一点代码来查找丢失的字体。 如果是脚本,则返回“已安装”或“不可用” 当它是一个应用程序时,它返回«常数****fsIn»或«常数****fsNA» 我想一个解决办法是让它只寻找fsIn,但我仍然想了解这里发生了什么 tell application id "com.adobe.InDesign" tell active document set fontStatus to (status of every font) repeat with s

我得到了一点代码来查找丢失的字体。 如果是脚本,则返回“已安装”或“不可用” 当它是一个应用程序时,它返回«常数****fsIn»或«常数****fsNA»

我想一个解决办法是让它只寻找fsIn,但我仍然想了解这里发生了什么

tell application id "com.adobe.InDesign"
    tell active document
        set fontStatus to (status of every font)
        repeat with s in fontStatus
            display dialog (s as string)
        end repeat
    end tell
end tell

显示对话框
属于不同范围内的标准添加项。 尝试将常量设置为Indesign范围内的变量

tell application id "com.adobe.InDesign"
    tell active document
        set fontStatus to (status of every font)
        repeat with s in fontStatus
            set fontStatusString to s as string
            display dialog fontStatusString
        end repeat
    end tell
end tell

显示对话框
属于不同范围内的标准添加项。 尝试将常量设置为Indesign范围内的变量

tell application id "com.adobe.InDesign"
    tell active document
        set fontStatus to (status of every font)
        repeat with s in fontStatus
            set fontStatusString to s as string
            display dialog fontStatusString
        end repeat
    end tell
end tell

这很正常。Apple事件使用“四字符代码”,而不是人类可读的名称。 在脚本编辑器中运行脚本时,AppleScript已经加载了应用程序的术语(因为需要从源代码编译为脚本),因此可以使用它将这些代码转换回人类可读的名称

当您将脚本另存为独立应用程序时,它已编译,因此默认情况下不会加载应用程序的术语。您可以使用条件块:

repeat with aConstantRef in fontStatus
    set theConstant to contents of aConstantRef
    if theConstant is installed then 
        set constantName to "installed"
    else if theConstant is not available then
        set constantName to "not available"
    ...
    else -- catch-all in case you miss any
        set constantName to theConstant as string
    end if
end repeat
或者,您可以强制AppleScript在运行时加载应用程序的术语,方法是包含编译针对该应用程序的“虚拟”脚本的
run script
命令:

run script "tell application id \"com.adobe.InDesign\" to (not available)"

之后,您的主脚本也应该可以使用该术语。

这很正常。Apple事件使用“四字符代码”,而不是人类可读的名称。 在脚本编辑器中运行脚本时,AppleScript已经加载了应用程序的术语(因为需要从源代码编译为脚本),因此可以使用它将这些代码转换回人类可读的名称

当您将脚本另存为独立应用程序时,它已编译,因此默认情况下不会加载应用程序的术语。您可以使用条件块:

repeat with aConstantRef in fontStatus
    set theConstant to contents of aConstantRef
    if theConstant is installed then 
        set constantName to "installed"
    else if theConstant is not available then
        set constantName to "not available"
    ...
    else -- catch-all in case you miss any
        set constantName to theConstant as string
    end if
end repeat
或者,您可以强制AppleScript在运行时加载应用程序的术语,方法是包含编译针对该应用程序的“虚拟”脚本的
run script
命令:

run script "tell application id \"com.adobe.InDesign\" to (not available)"
在此之后,您的主脚本也应该可以使用该术语