2013-10-28 44 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行。

可能有辦法繞開這個需要,比如刪除&重新應用代碼的簽名,但是我沒有打算弄清楚。

相關問題