2012-03-27 61 views
4

我在使用Mac OSX 10.7.3上的簡單AppleScript時遇到問題。 以下簡單的AppleScript我發現無處不在OSX引發錯誤'The action'運行AppleScript'遇到錯誤'使用AppleScript在Mac OSX Lion上單擊菜單項

我打開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" 
+0

這似乎不是一個編程問題,而是一個「如何使用」或「高級用戶」問題,最好問[su]。 – 2012-03-27 13:14:12

回答

4

是否啓用Enable access for assistive devices?如果是這樣,你是否試圖重新啓用它?

+1

好的。似乎是Mac OSX系統中的一個錯誤。 在'System Preferences> Universal Access'中,選擇框'Enable access for assistive devices'啓用,這對我的意圖是正確的。 現在我停用它,再次運行腳本 - 錯誤。正確。 然後我重新激活,再次運行腳本 - 工作!正確! – 2012-03-27 13:32:48

3

嗯,我想我會回答這個問題無論如何(並感謝編輯你的問題,給一點更有用的細節)。

轉到系統偏好設置中的「通用訪問」窗格並在「查看」選項卡底部,您會看到一個「啓用輔助設備訪問」複選框。

Enable Assistive Devices 打開它,我懷疑Automator會工作。