1

我有一个简单的 Applescript,它在您选择的文件夹中拍摄许多图像,然后使用图形转换器镜像图像。如果我把它放在一个新的 AS 文件中,这个脚本就会运行;但是,如果我再次尝试运行它,我会收到以下错误“无法获取应用程序“GraphicConverter”的窗口 1。无效索引。”

此脚本始终在 OSX 10.6 上运行

我正在运行 OSX 10.7.4 和 Graphic Converter 8.1(最新版本)。

这是脚本

tell application "Finder"
   activate
   set loopFinish1 to 0
   set pathName to (choose folder with prompt "Choose Folder Containing Images")
   set fileList1 to every file of folder pathName
   set loopFinish1 to count of items of fileList1
end tell

tell application "GraphicConverter"
   activate
   repeat with i from 1 to loopFinish1
       set currentFile to item i of fileList1
       open currentFile as alias
       mirror window 1 in horizontal
       close window 1 saving yes
   end repeat
end tell

这真让我抓狂!

4

1 回答 1

2

GraphicConverter有其他窗口(可见和不可见),最好使用文档来获取正确的窗口。另外,也许图像没有打开,所以没有窗口,使用try块。

activate
set pathName to (choose folder with prompt "Choose Folder Containing Images")
tell application "Finder" to set fileList1 to (document files of folder pathName) as alias list

tell application "GraphicConverter"
    activate
    repeat with tFile in fileList1
        set currentDoc to open tFile
        set CurrWindow to (first window whose its document is currentDoc)
        mirror CurrWindow in horizontal
        close currentDoc saving yes
    end repeat
end tell
于 2012-07-09T22:44:46.603 回答