2012-03-20 70 views
0

是否可以在Snow Leopard,Lion和Mountain Lion上以編程方式啓用MAC OS X輔助技術?以編程方式啓用MAC OSX輔助技術?

我有一個客戶端,需要在Universal Access中選中「啓用輔助設備訪問」複選框。這適用於預計將在雪豹,獅子和山獅上運行的應用程序。

它可以通過嵌入在Objective C應用程序中的Applescript或shell腳本來完成,或者必須由用戶手動明確地啓用嗎?

回答

0

試試這個:

tell application "System Events" 
activate 
set UI elements enabled to true 
end tell 
1

這是我用什麼...

enable_GUI_scripting() 

on enable_GUI_scripting() 
    try 
     if (system attribute "sysv") < 4138 then display dialog "This script requires the installation of Mac OS X 10.3 or higher." buttons {"Cancel"} default button 1 with icon 2 
     tell application "System Events" to if not UI elements enabled then 
      tell me 
       activate 
       display dialog "This script requires the built-in Graphic User Interface Scripting architecture of Mac OS X, which is currently disabled." & return & return & "Enable GUI Scripting now? (You may be asked to enter your password.)" buttons {"Cancel", "Enable"} default button 2 with icon 2 
      end tell 
      set UI elements enabled to true 
      if not UI elements enabled then error number -128 
     end if 
     return "yes" 
    on error 
     return "no" 
    end try 
end enable_GUI_scripting