mho*_*gan 7 mac bluetooth applescript automator osx-mountain-lion
我正在尝试创建一个 applescript 以允许我通过蓝牙 ID 连接到蓝牙设备。
到目前为止,如果蓝牙关闭,我已经设法获得一个applescript来打开蓝牙。这是代码:
# This is only necessary, if AppleScripts are not yet allowed to change checkboxes
tell application "System Events" to set UI elements enabled to true
# Now change the bluetooth status
tell application "System Preferences"
set current pane to pane id "com.apple.preferences.bluetooth"
tell application "System Events"
tell process "System Preferences"
# Enabled is checkbox number 2
if value of checkbox 2 of window "Bluetooth" is 0 then
click checkbox 2 of window "Bluetooth"
end if
end tell
end tell
quit
end tell
Run Code Online (Sandbox Code Playgroud)
有人会知道是否以及如何设置新的蓝牙设备,以及是否可以根据设备名称/设备蓝牙 ID 连接到设备?
我还尝试在 Automator 中记录操作,但是对于“设置新设备”选项,Automator 只是告诉我:“单击“按钮”。谢谢
小智 5
感谢@mu3 在评论中提供的这个链接,我设法做到了。这是苹果脚本:
activate application "SystemUIServer"
tell application "System Events"
tell process "SystemUIServer"
-- Working CONNECT Script. Goes through the following:
-- Clicks on Bluetooth Menu (OSX Top Menu Bar)
-- => Clicks on device Item
-- => Clicks on Connect Item
set btMenu to (menu bar item 1 of menu bar 1 whose description contains "bluetooth")
tell btMenu
click
tell (menu item "Beats Solo³ de Anthonin" of menu 1)
click
if exists menu item "Connect" of menu 1 then
click menu item "Connect" of menu 1
return "Connecting..."
else
key code 53 -- Close main BT drop down if Connect wasn't present
return "Connect menu was not found, are you already connected?"
end if
end tell
end tell
end tell
end tell
Run Code Online (Sandbox Code Playgroud)
您所要做的就是将“Beats Solo³ de Anthonin”替换为您的设备名称,如果您的计算机不是英文,请将“Connect”替换为您语言的翻译。
希望这可以帮助 :)
| 归档时间: |
|
| 查看次数: |
5553 次 |
| 最近记录: |