预期的行尾,但在脚本编辑器中找到了标识符

时间:2019-06-20 23:49:24

标签: applescript

我试图右键单击应用程序“ Pro Tools”中的按钮。

为此,我试图告诉脚本编辑器/苹果脚本使用向下控制(在Mac上模拟右键)来单击按钮。但是,当我尝试编译或运行代码时,总是收到错误消息。我收到语法错误消息,提示

  

预期的行尾等,但找到了数字。

  

预计行尾但找到了标识符。

表示使用。

tell application "System Events"
    tell application process "Pro Tools"
        click button "Record Enable" of group "Normal Transport Buttons" of group "Transport View Cluster" of window "Edit: BB MASTER TEMPLATE 2019 v1-14 copy" using key code 59
    end tell
end tell

我也尝试使用此代码:

tell application "System Events"
    (click button "record enable" of group "normal transport buttons" of group "transport view cluster" of window "Edit: BB MASTER TEMPLATE 2019 v1-14 copy" of application process "Pro Tools")
    using key code 59
end tell

1 个答案:

答案 0 :(得分:0)

首先,如果使用嵌套的Tell块,将使您的生活更加轻松,

tell application "System Events"
    tell application process "Pro Tools"
        tell window "Edit: BB MASTER TEMPLATE 2019 v1-14 copy"
            tell group "Transport View Cluster"
                tell group "Normal Transport Buttons"
                    click button "Record Enable"
                end tell
            end tell
        end tell
    end tell
end tell

是的,占用更多空间,但是调试起来容易得多。

话虽如此,您可以尝试使用perform命令而不是clickkey code。我的意思是,如果有一个等效的键可以右键单击最简单的按钮,请使用:

tell application "System Events"
    tell application process "Pro Tools"
        key code 59 using control down  *-- or whatever*
    end tell
end tell

但如果没有,请首先尝试:

tell application "System Events"
    tell application process "Pro Tools"
        tell window "Edit: BB MASTER TEMPLATE 2019 v1-14 copy"
            tell group "Transport View Cluster"
                tell group "Normal Transport Buttons"
                    tell button "Record Enable"
                        log properties
                        log actions
                    end tell
                end tell
            end tell
        end tell
    end tell
end tell

,并且如果日志中显示了似乎是针对按钮的操作,则可以使用以下命令直接调用它:

                tell group "Normal Transport Buttons"
                    tell button "Record Enable"
                        perform action 2 *-- or whatever*
                    end tell
                end tell

没有更多信息很难说更多...

相关问题