【问题标题】:Applescript w/Keynote. Accessing shapes within a slideApplescript w/Keynote。访问幻灯片中的形状
【发布时间】:2015-01-28 22:04:05
【问题描述】:

我有一个模板化的 Keynote 文件,其中包含一些幻灯片,所有幻灯片中都有 2 个形状。我希望能够说“嘿,给我幻灯片 2 的形状 2”之类的话。这样做的目的是让我可以将文本项直接添加到该形状。下面是我现在的代码。

我正在使用最新的 Keynote 6.5.2 和 Yosemite。

  tell application "Keynote"

        activate

        tell document 1

            set anniversary to "Anniversaries"
            set myShape to shape 2 of slide 2
            tell myShape 
                set thisTextItem to make new text item with properties {object text:anniversary}
                #log thisTextItem
                tell thisTextItem
                    set the size of its object text to 144
                    set the color of its object text to "blue"
                end tell

            end tell

        end tell

    end tell

我可以自己告诉幻灯片 2,当然我会得到幻灯片 2 的大文本项,其中包含文本“周年纪念日”和蓝色,但它唯一的幻灯片 2...不在幻灯片 2 的形状 2 内。

使用此代码,运行脚本时会弹出错误:

结果:

error "Keynote 出现错误:无法将该元素制作或移动到该元素中 容器。”编号-10024

这是什么意思?我无法访问幻灯片中的形状吗?在幻灯片中的形状内设置文本的任何帮助/信息/示例都是有益的。谢谢!

【问题讨论】:

    标签: applescript osx-yosemite keynote


    【解决方案1】:

    形状可以设置文本的属性,不能在形状中插入text item对象。

    tell application "Keynote"
        tell document 1
            tell shape 2 of slide 2
                set object text to "Anniversaries"
                tell object text
                    set it's size to 44
                    set it's color to {0, 0, 65535} -- blue
                end tell
            end tell
        end tell
    end tell
    

    【讨论】:

    • 谢谢。经过研究,我确定了这一点。如果您想看一下,另一个问题会出现:)
    猜你喜欢
    • 1970-01-01
    • 2019-02-20
    • 1970-01-01
    • 2010-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多