【问题标题】:Click menu item on Mac OSX Lion using AppleScript使用 AppleScript 在 Mac OSX Lion 上单击菜单项
【发布时间】:2012-04-11 00:30:09
【问题描述】:

我在 Mac OSX 10.7.3 上使用简单的 AppleScript 时遇到问题。 使用以下简单的 AppleScript,我在任何地方都能找到 OSX 引发错误““运行 AppleScript”操作遇到错误”

我打开 Automator,创建一个服务,放入“运行 AppleScript”节点并输入以下代码,我认为这是正确的,因为正如我所说,这是很多人毫无怨言的做法。

AppleScript:

tell application "Terminal" to activate
    tell application "System Events"
        tell process "Terminal"
            click menu item "New Window" of menu "Shell" of menu bar 1
            tell application "Terminal" to close the front window
        end tell
end tell

编辑:在 Automator 中运行时,我还会收到错误描述:

Run AppleScript failes -1 error
Access for assistive devices is disabled"

【问题讨论】:

  • 这似乎不是一个编程问题,而是一个“如何使用”或“高级用户”问题,最好在 Super User 上提出。

标签: applescript applescript-objc


【解决方案1】:

Enable access for assistive devices 是否启用?如果是这样,您是否尝试过重新启用它?

【讨论】:

  • 好的。似乎是 Mac OSX 系统中的一个错误。在System Preferences > Universal Access 中,选择框Enable access for assistive devices 处于活动状态,这符合我的意图。现在我停用它,再次运行脚本 - 错误。正确的。然后我重新激活,再次运行脚本 - 工作!正确!
【解决方案2】:

好吧,我想我还是会回答这个问题(感谢您编辑您的问题以提供更多有用的细节)。

转到“系统偏好设置”中的“通用访问”窗格,在“查看”选项卡的底部,您会看到“启用辅助设备访问”复选框。

打开它,我怀疑 Automator 会工作。

【讨论】:

    猜你喜欢
    • 2021-11-25
    • 1970-01-01
    • 2011-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-31
    • 2013-05-05
    • 1970-01-01
    相关资源
    最近更新 更多