2013-08-08 11 views
6

Ben böyle Güvenlik & Gizlilik seçenekleri penceresini açın biliyor? Kullanıcıların doğru ekranı bulmasını kolaylaştırmak istiyorum. Erişilebilirlik API'sının şu anda devre dışı bırakıldığını unutmayın; bu, Gizlilik sekmesinde etkinleştirmeye çalıştığım şeydir. (Bu bir new feature in 10.9'dur.)Kullanıcıları otomatik olarak Sistem Tercihleri ​​➞ Gizlilik'e yönlendirebilir miyim?</p> <pre><code>open /System/Library/PreferencePanes/Security.prefPane </code></pre> <p>programlı Gizlilik sekmesine gidin mümkün mü:

cevap

6

AXProcessIsTrustedWithOptions'u daha önce bulduğunuz, kullanıcının gizlilik erişilebilirlik ayarlarına doğrudan erişmesini sağladığınız your answer to the other topic; Muhtemelen the official alert provided by that function'dan daha az şaşkınlık ve şüphe uyandıran kendi kullanıcı istemi uygulamak isteyeceksiniz.

Sen Güvenlik & Gizlilik tercihleri ​​bölmesini açın ve kullanarak Erişilebilirlik bölümüne düz gezinebilirsiniz AppleScript:

:

tell application "System Preferences" 
    --get a reference to the Security & Privacy preferences pane 
    set securityPane to pane id "com.apple.preference.security" 

    --tell that pane to navigate to its "Accessibility" section under its Privacy tab 
    --(the anchor name is arbitrary and does not imply a meaningful hierarchy.) 
    tell securityPane to reveal anchor "Privacy_Accessibility" 

    --open the preferences window and make it frontmost 
    activate 
end tell 

Seçeneklerden biri AppleScript Editor ile bir applescript dosyaya bu kaydedip doğrudan yürütmektir

osascript path/to/applescript.scpt 

Eşdeğer komutları, Object C uygulamasından, Scripting Bridge yoluyla da gerçekleştirebilirsiniz. Bu, Sistem Tercihleri ​​komut dosyası API'sini betimleyici nesneler olarak ortaya çıkaran bir Objective C üstbilgisi (Apple'ın komut satırı araçlarını kullanarak) oluşturmanız gerektiğine daha da fazla katkıda bulunuyor. (Kafayla nasıl oluşturulacağı ile ilgili ayrıntılar için Apple's Scripting Bridge documentation bakınız.)


Düzenleme: Bir Sistem Tercihleri ​​başlığı oluşturduktan sonra aşağıdaki Objective C kodu yukarıdaki AppleScript aynı işi yapar:

//Get a reference we can use to send scripting messages to System Preferences. 
//This will not launch the application or establish a connection to it until we start sending it commands. 
SystemPreferencesApplication *prefsApp = [SBApplication applicationWithBundleIdentifier: @"com.apple.systempreferences"]; 

//Tell the scripting bridge wrapper not to block this thread while waiting for replies from the other process. 
//(The commands we'll be sending it don't have return values that we care about.) 
prefsApp.sendMode = kAENoReply; 

//Get a reference to the accessibility anchor within the Security & Privacy pane. 
//If the pane or the anchor don't exist (e.g. they get renamed in a future OS X version), 
//we'll still get objects for them but any commands sent to those objects will silently fail. 
SystemPreferencesPane *securityPane = [prefsApp.panes objectWithID: @"com.apple.preference.security"]; 
SystemPreferencesAnchor *accessibilityAnchor = [securityPane.anchors objectWithName: @"Privacy_Accessibility"]; 

//Open the System Preferences application and bring its window to the foreground. 
[prefsApp activate]; 

//Show the accessibility anchor, if it exists. 
[accessibilityAnchor reveal]; 

Ancak, Scripting Bridge uygulamasının korumalı uygulamalar tarafından kullanılmadığını (en son kontrol ettiğimi) unutmayın.

+0

Teşekkür ederiz! Evet, sadece bir tıklatma tıklaması ve tüm kullanıcıların kolayca görmezden geleceği bazı korkutucu metinlerin yanı sıra kullanıcıyı herhangi bir değer eklemeden Sistem Tercihleri'ne yönlendiren aptal sistem diyaloğundan kaçınmaya çalışıyorum. – zoul

İlgili konular