2011-09-21 57 views

回答

5

您可以使用OS X私有API IOBluetoothPreferenceSetDiscoverableState。

// Declaration of private API 
void IOBluetoothPreferenceSetDiscoverableState(int discoverable); 
int IOBluetoothPreferenceGetDiscoverableState(); 

// Usage 
// Turn on Discoverability 
IOBluetoothPreferenceSetDiscoverableState(1); 
// Get current discoverable state 
IOBluetoothPreferenceGetDiscoverableState() 

您可能還會發現這些API用於打開和關閉藍牙有用:

void IOBluetoothPreferenceSetControllerPowerState(int powered); 
int IOBluetoothPreferenceGetControllerPowerState(); 
1

告訴應用程序 「系統偏好設置」

set current pane to pane "com.apple.preferences.Bluetooth" 
tell application "System Events" 
    tell process "System Preferences" 
     set isOnCheckbox to checkbox "On" of window "Bluetooth" 
     if value of isOnCheckbox is 0 then 
      click isOnCheckbox 
     end if 
    end tell 
end tell 
quit 

末告訴

這個蘋果腳本將開啓/關閉藍牙visibility.Hope這將幫助。

相關問題