用脚本断开蓝牙设备(mac os x)

时间:2017-12-14 08:08:31

标签: bash macos bluetooth applescript

我正在寻找一种方法来断开Mac上的蓝牙设备与脚本(可以是苹果脚本,bash cmd,python等)。任何可以添加到其他脚本的东西。

我不想关闭蓝牙,只关闭所选设备。

目前,我是使用右上方的命令栏手动完成的 - >蓝牙 - >设备 - > XXX - >断开。

我试过(感谢@Janek评论)这个脚本:

set btDevice to "Smart Reader 2501"

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
    tell (first menu item whose title is btDevice) of menu of bt
        click
        tell menu 1
            if exists menu item "Disconnect" then
                click menu item "Disconnect"
            else if exists menu item "Déconnecter" then
                click menu item "Déconnecter"
            else
                click bt -- close main dropdown to clean up after ourselves
            end if
        end tell
    end tell
end tell

但我发现这种方法存在三个问题:

  • 它依赖于语言(所以我需要两行语言)
  • 我们会看到所有操作(因此对用户来说不是非常有意义)
  • 最重要的是:断开连接后设备会重新连接

对于最后一个,它可能与蓝牙设备配对处理有关,我怀疑我永远无法断开它。

但如果你有任何其他线索,我会接受它!

由于

0 个答案:

没有答案
相关问题