有没有办法将AppleScript与注释记号一起使用,这样我就可以激活文本对象的编号项目符号和列表?

有没有办法将AppleScript与注释记号一起使用,这样我就可以激活文本对象的编号项目符号和列表?,applescript,keynote,Applescript,Keynote,我想自动格式化Swift中的代码,从Xcode复制并粘贴到Keynote中的文本字段中。格式确实是继承了,但我想改变字体大小,我已经做了,进一步我想添加行号,这可以通过项目符号和类型编号列表手动完成 我写了一个AppleScript程序,它只改变字体的大小 我的代码如下所示: tell application "Keynote" activate set ts to the current slide of the front document tell ts

我想自动格式化Swift中的代码,从Xcode复制并粘贴到Keynote中的文本字段中。格式确实是继承了,但我想改变字体大小,我已经做了,进一步我想添加行号,这可以通过项目符号和类型编号列表手动完成

我写了一个AppleScript程序,它只改变字体的大小

我的代码如下所示:

tell application "Keynote"
    activate
    set ts to the current slide of the front document
    tell ts
        set theTextItem to its first text item
        tell theTextItem
            set the size of its object text to 32
        end tell

    end tell
end tell

此代码将文本对象的大小更改为32,但我找不到激活行号的方法,即激活项目符号和列表中的数字格式。

TI发现iWork中的项目符号和编号是富文本格式的一部分,AppleScript无法直接访问该格式。但是,您可以通过GUI脚本编写来完成这一点,只需稍加努力,如下所示:

tell application "Keynote"
    activate
    tell front document
        tell current slide
            set theTextItem to its second text item
        end tell
        -- this selects the text item
        set selection to theTextItem
    end tell
end tell

tell application "System Events"
    tell process "Keynote"
        tell first window
            -- this makes sure the panel is set to the 'Text' tab
            tell first radio group's radio button "Text"
                if its value = 0 then
                    click
                end if
            end tell
            tell scroll area 1
                -- this finds the correct button, then clicks it to open the popover
                set popoverButton to (first button whose help is "Choose a list style.")
                tell popoverButton
                    click
                    tell first pop over's first scroll area's first table
                        -- this finds the table row in the popover for creating a numbered list
                        -- and selects it. You can substitute in 'Bullet', 'Image', 
                        -- 'Lettered' or any other label in the popover. 
                        select (first row whose first UI element's first text field's value contains "Numbered")
                    end tell
                end tell
            end tell
        end tell
    end tell
end tell

这并不漂亮,但它完成了任务。

这只是一个推论,但我怀疑项目符号和编号是文本项和其他iWork项所指的富文本对象的一部分。AppleScript从来没有一个有效处理富文本的系统。您可能会遇到一些棘手的问题,例如在“文本编辑”中为带项目符号的富文本对象编写脚本,然后将其复制到注释记号中。如果你认为值得的话,我可以调查一下。非常感谢!它确实管用,你知道为什么Keynote实际上会为列表样式保留西班牙语和英语的混合名称吗?我目前使用英语作为系统语言,但Keynote精确地保留了西班牙语的列表样式。我把号码改成了Número,正如我所说,它工作得很好。谢谢你!Keynote有一个菜单项--File->Advanced->Language&Region--允许您为演示文稿本身设置可能不同于定义的系统语言的特定语言。这是唯一一件冲我跳出来的事。哦,等等。。。您还可以通过点击“+”按钮在“列表”弹出窗口中定义自定义列表样式,并用您喜欢的任何语言命名这些样式。如果这是一个旧的演示文稿,那么链上的某个人可能已经用另一种语言定义了样式。