2012-03-20 32 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