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
解决方案
首先,如果你使用嵌套的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
命令而不是click
or key 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
如果没有更多信息,很难说更多……
推荐阅读
- time-series - 时间序列 acf、pacf 和 model_fit 问题
- python - 如何将查询结果格式化为我的扩展字典对象?
- python - 从 WaldTestResults pandas DataFrame 中提取值
- c++ - C++ 可变参数模板打包到 std::array 并解包
- asp.net-mvc - 如何使用下拉菜单实现 ASP.NET MVC 验证
- django - 如何优化查询 django
- javascript - 在 Next.js 中的文件上传期间,API 解决而没有响应
- c - 代码应用程序在第二个被读取后停止工作
- java - 在Java图形(JFrame)中使用for循环反转“楼梯”
- apache-spark - 使用 pyspark 实现 SCD type2