Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Applescript 如何在当前注释记号文档中的当前幻灯片上选择一个特定图像?_Applescript_Keynote_Iwork - Fatal编程技术网

Applescript 如何在当前注释记号文档中的当前幻灯片上选择一个特定图像?

Applescript 如何在当前注释记号文档中的当前幻灯片上选择一个特定图像?,applescript,keynote,iwork,Applescript,Keynote,Iwork,使用AppleScript,我想更改注释记号文档的每张幻灯片上特定图像的x和y位置。运行并激活Keynote后,以下代码将正常工作 tell the front document set the current slide to slide 1 tell the current slide set thisImage to image 1 set position of thisImage to {10,10} end tell -- current s

使用AppleScript,我想更改注释记号文档的每张幻灯片上特定图像的x和y位置。运行并激活Keynote后,以下代码将正常工作

tell the front document
   set the current slide to slide 1
   tell the current slide
      set thisImage to image 1
      set position of thisImage to {10,10}
   end tell -- current slide
end tell -- front document
。。。但它太脆弱了。如果我的图像不是第一个(“图像1”),那么我将更改错误对象的位置。我在脚本字典或在线示例中找不到任何关于为特定图像表达对象说明符的内容。我尝试了一些变化,比如

set thisImage to image with file name "my-file.png"

。。。无济于事。任何和所有的建议都将不胜感激。谢谢

这在Keynote 8.2中有效,但老实说,我不知道为什么

set thisImage to image {name:"my-file.png"}
然而,如果你想问这个图像的名字是什么,你必须问它的文件名,例如

每次我使用任何演示软件,不知何故我都不太喜欢它们

您有一些冗余(在“当前幻灯片”周围),因此我的观点如下:

tell slide 1 of the front document
    set thisImage to image {name:"my-file.png"}
    set position of thisImage to {10, 10}
end tell
最后,由于您的目标是循环浏览幻灯片组中的每一张幻灯片,您可以尝试以下方法:

tell front document
    repeat with i from 1 to count of slides

        tell slide i to set position of image {name:"my-file.png"} to {10, 10}

    end repeat
end tell

进一步检查后,前面的答案不起作用,或者不再起作用。显然名称说明符

set thisImage to image {name:"my-file.png"}
。。。实际上并没有以这种方式指定名称。以下是我丑陋的解决方法:

tell the current slide
    set imageCount to the count of images
    repeat with i from 1 to imageCount
        set thisImage to image i
        if file name of thisImage = "myTargetFile.png" then
            set position of thisImage to {10, 10}
            exit repeat -- Ugly programming, look away.
        end if
    end repeat
end tell

您的解决方案也适用于Keynote 9.2。非常感谢。
tell the current slide
    set imageCount to the count of images
    repeat with i from 1 to imageCount
        set thisImage to image i
        if file name of thisImage = "myTargetFile.png" then
            set position of thisImage to {10, 10}
            exit repeat -- Ugly programming, look away.
        end if
    end repeat
end tell