【发布时间】:2019-03-30 13:33:46
【问题描述】:
我希望能够通过 Windows Powershell 执行 Adobe Illustrator ExtendScript。我相信这应该是可能的,因为this answer 描述了通过 COM 使用 VB。
这是我的 Powershell 脚本:
$illustratorRef = New-Object -ComObject Illustrator.Application
$conversionScript = New-Object -ComObject Scripting.FileSystemObject
$scriptFile = $conversionScript.OpenTextFile("C:\ws\ArtConversion\alert-test.jsx")
$fileContents = $scriptFile.ReadAll()
$scriptFile.Close()
$fileToRun = $fileContents + "main(arguments)"
$args = "line1", "line2"
$illustratorRef.DoJavaScript($fileToRun, $args, 1)
这是alert-test.jsx 脚本:
function main(argv) {
alert('message: ' + argv[0]);
return argv[0];
}
运行 Powershell 脚本会打开 Illustrator,但遇到 $illustratorRef.DoJavaScript 时会引发以下错误:
Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED))
我正在使用 Adobe Illustrator 2019 CC(64 位)和 Powershell 5.1.16299.666
【问题讨论】:
标签: powershell com adobe-illustrator extendscript