有没有一种方法可以在OS X中以编程方式设置蓝牙可发现模式(true/false)?而不是要求用户打开/关闭它?
// 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();
告诉应用程序“系统偏好设置”
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
结束告诉
这个苹果脚本将开启/关闭蓝牙可见性。希望这能帮到你。