I would like to connect to my jbl quantum910 via a shortcut

i think it is pretty annoying that i have to

  1. open settings
  2. press bluetooth
  3. hover over jbl quantum
  4. press connect
    is there a one click solution for this?

t tried this: (from Claude)

– AppleScript für macOS Ventura/Sonoma und neuer
– Speichere als .scpt oder exportiere als App

tell application "System Settings"
	activate
	delay 1
	reveal pane id "com.apple.BluetoothSettings"
end tell

delay 3

tell application "System Events"
	tell process "System Settings"
		try
			-- Suche nach JBL Quantum910 in der Geräteliste
			set deviceFound to false
			repeat with i from 1 to 20
				try
					-- Verschiedene UI-Strukturen probieren
					set deviceButtons to buttons whose name contains "JBL Quantum910"
					if (count of deviceButtons) > 0 then
						set targetButton to item 1 of deviceButtons
						click targetButton
						delay 1
						
						-- Nach Connect/Verbinden Button suchen
						try
							click button "Connect" of window 1
							set deviceFound to true
							exit repeat
						on error
							try
								click button "Verbinden" of window 1
								set deviceFound to true
								exit repeat
							end try
						end try
					end if
				end try
				delay 0.5
			end repeat
			
			if not deviceFound then
				-- Alternative: Direkt über Menü versuchen
				tell application "System Events"
					tell process "Control Center"
						-- Control Center Bluetooth-Icon anklicken
						try
							click menu bar item 1 of menu bar 1
							delay 1
							click button "Bluetooth" of window 1
							delay 1
							click button "JBL Quantum910" of window 1
						end try
					end tell
				end tell
			end if
			
		on error errMsg
			display dialog "Fehler beim Verbinden: " & errMsg
		end try
	end tell
end tell

-- System Settings wieder schließen
tell application "System Settings"
	quit
end tell

but it didn’t work

Thanks for any help.

It looks like you’re running MacOS under German language settings correct? “System Settings”, “Control Center” and other strings will have to match the appropriate application names under your current language.

Make sure you have any accessibility settings set.

Check the log in your script editor for errors.

Also insert. Various log statements at positions in your script to know how far you get, possibly posting results.

Maybe change some stuff to get a list of every button name.

Then log that

Also possibly play with some
Delays,
As
It may take a while
For those
Buttons to show

I this you may also want to narrow down where your getting the buttons from…

right now you are asking the application.
I think you want to tell application process.

Then tell window 1 or even narrows it down further to get the right buttons.

This sounds very promising…but…i can see that running the script opens the systems settings and also opens the bluetooth tab.

actually a very good idea. But i ended up using blueutil

First i wanna thank both of you for your answers which both sounded promising.

I am a totally noob in scripting…so i kept asking Chatgpt and it recommended using blueutil.

i finally was successful with this script:

set blueutilPath to ""
try
	set blueutilPath to do shell script "which blueutil"
on error
	set blueutilPath to ""
end try

-- 2) fallback: bekannte Homebrew-Pfadoptionen
if blueutilPath is "" then
	if (do shell script "test -x /opt/homebrew/bin/blueutil && echo 1 || echo 0") is "1" then
		set blueutilPath to "/opt/homebrew/bin/blueutil"
	else if (do shell script "test -x /usr/local/bin/blueutil && echo 1 || echo 0") is "1" then
		set blueutilPath to "/usr/local/bin/blueutil"
	end if
end if

-- 3) wenn nicht gefunden -> Hinweis und Abbruch
if blueutilPath is "" then
	display dialog "blueutil wurde nicht gefunden. Installiere mit:

brew install blueutil" buttons {"OK"} default button "OK"
	return
end if

do shell script (quoted form of blueutilPath & " --connect " & quoted form of "JBL Quantum910")

ChatGPT is a moron.

Next time, have a gander at the IOBluetooth framework.

I think the UI stuff depends on your system version. I’m on 12.4 and investigating the UI you have to access the pop of menu of the table of the outline view of the window.

You have to access the rows of the table view.
Check its first text field for the name.
2nd text field has the connection status

The select the appropriate row.
Then perform the AXShowMenu of the table and then select the connect menu item