2013-10-28 47 views
4

我有一个脚本,用于在多监视器设置上布局窗口。 升级到小牛后,我发现了一个错误:“某些脚本”不允许小牛的辅助访问错误

Organize Windows is not allowed assistive access. 

检查苹果的支持后,我发现这一点:http://support.apple.com/kb/HT5914 我跟着那里描述的步骤,我签署了小程序,但没有成功。错误仍然发生。

首先,如果脚本作为应用程序导出并放置在/ Applications中,并且放置在Documents(也像应用程序一样捆绑在一起)中,例如它不弹出,则只会发生第二个提示。

所有小程序在显示时都显示为系统偏好设置中的“小程序”(由于它们有标识符,这很奇怪)。

有没有人有过任何成功运行这种脚本?有没有办法在全球范围内禁用安全检查? (我相信不是,但它是值得问)

接下来是脚本,它只是推出了几个应用程序,并把它们在屏幕上:

#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 

回答

6

我正好具有同样的问题我写的脚本应用程序,用于处理轻微音频故障。我将它设置为在启动时启动,允许它在辅助访问中,并在Apple Support上找到它,并且它在每次启动时仍然给我这个错误。

终于为我修复的是将脚本代码复制并粘贴到一个新的脚本文件中,作为应用程序另存为一个应用程序,但名称不同,并在我运行之前对其进行了签名。当我最终运行它时,它问我是否希望在Assistive Access中允许它,然后将它设置为像以前一样在启动时启动。我刚刚通过重新启动,它运行没有任何问题。

+2

Upvote。节省了我的时间。 – Ilan

+0

尝试运行'sudo sqlite3/Library/Application \ Support/com.apple.TCC/TCC.db“SELECT * FROM access”'查找为不工作的脚本添加的辅助访问条目。您应该看到类似于'kTCCServiceAccessibility | com.apple.ScriptEditor.id。<您的应用程序的名称>一行'| 1 | 1 | 1 |'一旦找到它,可以使用'sudo sqlite3/Library/Application \支持/ com.apple.TCC/TCC。db“DELETE FROM access WHERE client ='com.apple.ScriptEditor.id。<您的应用程序的名称>'”'。签署应用程序,运行它,并希望它没有重命名它的工作。 –

1

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

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

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

可能有办法绕开这个需要,比如删除&重新应用代码的签名,但是我没有打算弄清楚。

相关问题