自动连接蓝牙设备
剁手扫地机器人送了一个天猫精灵,拿来做电脑音箱了,之前苦恼的是在win下连接完之后回到mac需要移除再连一次比较麻烦,后面通过hackintool导出蓝牙注册表,在win下解决了问题,不过还是有点不爽,win下音箱在启动的时候会自动连接,mac每次都需要手动连接一次,想起手机上的“捷径”能帮我们做一些自动化的事情,一搜mac上果然也差不多。开整1、打开“自动操作”2、新建文稿
3、选择“应用程序”
4、双击选择“运行appleScript“
set DeviceName to "你的设备名称"
tell application "System Events" to tell process "SystemUIServer"
set bt to (first menu bar item whose description is "bluetooth") of menu bar 1
click bt
if exists menu item DeviceName of menu of bt then
tell (first menu item whose title is DeviceName) of menu of bt
click
tell menu 1
if exists menu item "连接" then
click menu item "连接"
return "Connected"
else
key code 53 -- hit Escape to close BT menu
return "No connect button; is it already connected?"
end if
end tell
end tell
else
key code 53 -- hit Escape to close BT menu
return "Cannot find that device, check the name"
end if
end tell
5、复制代码你的设备名称请务必一字不差
6、命名保存、将应用程序添加为“登陆项”
建议保存前通过“脚本编辑器”先测试一下
7、收工
审核机制有点毒 等我搞定了蓝牙就来搞你 按照这么操作可以开机连接蓝牙音箱了 ,但是会有这么一个报错 楼主太牛了,一下就成功了!{:5_280:} 有个bluetil插件装上后可以直接一条命令 连接对应设备的mac地址就行了。另外我记得白果好像开机可以自动连接蓝牙,不知道什么原理 use framework "IOBluetooth"
use scripting additions
set DeviceName to "设备名"
on getFirstMatchingDevice(DeviceName)
repeat with device in (current application's IOBluetoothDevice's pairedDevices() as list)
if (device's nameOrAddress as string) contains DeviceName then return device
end repeat
end getFirstMatchingDevice
on toggleDevice(device)
if not (device's isConnected as boolean) then
device's openConnection()
return "Connecting " & (device's nameOrAddress as string)
else
device's closeConnection()
return "Disconnecting " & (device's nameOrAddress as string)
end if
end toggleDevice
return toggleDevice(getFirstMatchingDevice(DeviceName))
页:
[1]