“某些脚本”不允许在小牛队出现辅助访问错误



我有一个脚本,用于在多显示器设置上布置窗口。升级到小牛队后,我收到一个错误:

Organize Windows is not allowed assistive access.

检查Apple支持后,我发现:http://support.apple.com/kb/HT5914我按照那里描述的步骤,在小程序上签名,但没有取得多大成功。错误仍然发生。

首先,仅当脚本导出为应用程序并放置在/Applications 中时,才会发生第二个提示,例如,如果我将其放置在文档中(也像应用程序一样捆绑),它不会弹出。

当所有小程序出现时,它们都会在"系统偏好设置"中显示为"小程序"(这很奇怪,因为它们有标识符)。

有没有人成功地运行这种脚本?有没有办法全局禁用安全检查?(我想不是,但值得一问)

接下来是脚本,它只是启动几个应用程序并将它们放在屏幕上:

#Query desktop area
tell application "Finder"
    set displayAreaDimensions to bounds of window of desktop
    set widthOfDisplayArea to item 3 of displayAreaDimensions
    set heightOfDisplayArea to item 4 of displayAreaDimensions
end tell
tell application "System Events" to tell process "Dock"
    set dockPosition to position in list 1
    set dockDimensions to size in list 1
    set heightOfDock to item 2 of dockDimensions
    set positionOfDock to item 2 of dockPosition
end tell
# Space between windows
set padding to 7
# This assumes that the Apple Cinema Display 27" is to the right
# of the Macbook Pro
set idea_w to 1600
set idea_h to 1440
set idea_base_x to 1680
set iterm_w to 2560 - idea_w - padding
set iterm_h to 1000
set iterm_base_x to idea_base_x + idea_w + padding
#If we're in a single monitor configuration
if widthOfDisplayArea is 1680 and heightOfDisplayArea is 1050 then
    # Override sizes
    set idea_base_x to 0
    set iterm_base_x to 0
    set idea_w to widthOfDisplayArea
    set idea_h to (heightOfDisplayArea - heightOfDock)
    set iterm_w to 1024
    set iterm_h to (heightOfDisplayArea - heightOfDock)
end if
checkRunning("IntelliJ IDEA 11", 10)
checkRunning("iTerm", 0)
placeWindow("IntelliJ IDEA", idea_base_x, 0, idea_w, idea_h)
placeWindow("iTerm", iterm_base_x, 0, iterm_w, iterm_h)
#Helper to launch as necessary
on checkRunning(theName, theDelay)
    if application theName is not running then
        tell application theName to activate
        delay theDelay
    end if
end checkRunning
on placeWindow(theProcess, x, y, w, h)
    tell application "System Events" to tell process theProcess
        set allWindows to (every window)
        repeat with aWindow in allWindows
            set position of aWindow to {x, y}
            set size of aWindow to {w, h}
        end repeat
    end tell
end placeWindow
我在编写

的脚本应用程序上遇到了完全相同的问题,以处理轻微的音频故障。我将其设置为在启动时启动,在辅助访问中允许它,并按照您在Apple支持上找到的方式对其进行签名,并且每次启动时它仍然给我这个错误。

最终为我修复它的是将脚本代码复制并粘贴到一个新的脚本文件中,再次将其保存为应用程序,但名称不同,并在我运行它之前对其进行签名。当我最终运行它时,它会询问我是否要在辅助访问中允许它,我做到了,然后我将其设置为像以前一样在启动时启动。我刚刚重新启动,它运行没有任何问题。

Red Five的回答很好,但还有几件事需要注意。

每当您编辑脚本以编辑辅助访问功能的使用时,签名和重新允许辅助访问仅适用于脚本中预先存在的辅助访问功能使用。辅助访问功能的新使用将产生"不允许 XYZ 辅助访问"错误。此时,将脚本内容复制到具有不同名称的新脚本似乎是使整个脚本能够使用辅助访问功能的唯一方法。 其他不涉及辅助访问功能的编辑将需要重新允许辅助访问,并且您无需复制脚本。 这使得调试辅助访问功能相当麻烦。

还值得注意的是,如果将代码包装在 try 块中,则不会看到"不允许 XYZ 辅助访问"错误,因此为了进行调试,您应该注释掉 try/end-try 行。

可能有一种方法可以规避这种需求,例如删除并重新应用代码的签名,但我还没有费心去弄清楚。

相关内容

最新更新