Applescript to connect to bluetooth device
        Posted  
        
            by 
                Mark117
            
        on Super User
        
        See other posts from Super User
        
            or by Mark117
        
        
        
        Published on 2012-08-31T08:56:56Z
        Indexed on 
            2012/08/31
            9:41 UTC
        
        
        Read the original article
        Hit count: 455
        
I'm trying to create an applescript to allow me to connect to a bluetooth device by it's Bluetooth ID.
So far, i've managed to get an applescript to turn on bluetooth if it's off. Here's the code:
# 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
Would someone know if and how it's possible to set up a new bluetooth device and if it'd be posible to connect to a device based on it's device name/ it's device bluetooth ID?
I've also tried to record the action in Automator but for the "set up new device" option, Automator just tells me: "click on "" button". Thanks
© Super User or respective owner