๐ BluetoothDeviceConnector is an AutoHotkey script that connects or disconnects a paired Bluetooth audio device with either stereo-only playback or stereo plus microphone support.
- Automatically searches for the specified paired Bluetooth device.
- Connects or disconnects the device using editable defaults or command-line arguments.
- Selects Stereo only (A2DP) or Stereo + microphone (A2DP + Hands-Free).
- Supports speaker-only devices that do not expose a Hands-Free profile.
- Provides visual notifications for success or errors.
- ๐ฎ Stream Deck Integration: One-click Bluetooth connection directly from your Elgato Stream Deck!
This project includes an official Stream Deck plugin that lets you connect your Bluetooth devices with a single button press!
- Install directly from the Elgato Marketplace or download from GitHub Releases
- Add the "Connect Bluetooth Device" action to your Stream Deck
- Pick your device and audio profile, then connect with one press!
- โ One-click connect/disconnect toggle
- ๐ Device picker โ choose a paired device from a dropdown in the Property Inspector
- ๐ง Per-key audio profile โ choose stereo-only A2DP or stereo plus the Hands-Free microphone on Windows
- ๐ Exclusive same-key handoff โ changing a key's device disconnects its previous target before connecting the new one
- ๐ Verified Windows audio routing โ a successful connection selects and verifies the matching default playback endpoint, and tries the Hands-Free microphone when available
- ๐ Speaker-only device support (Amazon Echo Dot, Bluetooth speakers, and devices without HFP)
- ๐ก Safe restart state โ Windows keys reapply their selected audio profile on the first press when device-wide Bluetooth status cannot prove the audio services are active
- ๐ฏ Visual feedback (Disconnected / Connecting / Connected / Error states)
- ๐ Fast and lightweight
โ Learn more about the Stream Deck plugin
- Operating System: Windows
- Libraries: The script uses the Bluetooth control library provided by Windows (
Bthprops.cpl). - System Icon: The script uses a system icon (requires the path
C:\WINDOWS\system32\netshell.dll). - AutoHotkey v2: Must be installed to run this script. Download AutoHotkey v2.
- Install AutoHotkey v2: Make sure AutoHotkey v2 is installed.
- Copy the code: Copy the script code into
bluetooth_device_connector.ahk. - Run the script: Double-click the
.ahkfile to run the script.
Modify the three variables at the beginning of the script. Existing behavior remains the default: connect AirPods Pro with stereo playback and its Hands-Free microphone enabled.
deviceName := "AirPods Pro"
action := "connect" ; "connect" or "disconnect"
audioProfile := "a2dp-hfp" ; "a2dp" or "a2dp-hfp"Use audioProfile := "a2dp" when you want stereo playback without enabling the Windows Hands-Free microphone profile.
The same values can be supplied without editing the file:
AutoHotkey64.exe bluetooth_device_connector.ahk "Echo Dot" connect a2dp
AutoHotkey64.exe bluetooth_device_connector.ahk "AirPods Pro" disconnect a2dp-hfpThe script uses the Windows Bluetooth Control Panel library (Bthprops.cpl) to find the desired device and manage two services:
- Handsfree: Connection for voice communications (e.g., calls).
- AudioSink: Connection for audio streaming (e.g., music).
Stereo-only mode disables Hands-Free before enabling AudioSink. Combined mode enables both services, while disconnect mode disables both. Devices that expose only one applicable audio service remain supported.
The script will display notifications in case of:
- No Bluetooth device found.
- Device successfully connected or disconnected.
- Invalid action or audio-profile configuration.
- Each launch operates on one configured device; use command-line arguments or separate script copies for multiple targets.
- The standalone script manages Bluetooth services but does not change the Windows default playback endpoint. The Stream Deck plugin includes verified default-device routing.
- It works only on Windows, using the Bluetooth libraries provided by the operating system.
You can customize the script to include more devices or add extra functionality. AutoHotkey is a versatile scripting language that allows you to automate many operations on Windows.
Contributions and improvements are welcome! Feel free to submit a pull request or report any issues on GitHub.
This project is completely free and open source. If you find it useful and would like to support its continued development and updates, consider making a donation. Your support helps keep the project alive and motivates me to add new features and improvements!
Every contribution, no matter how small, is greatly appreciated! โค๏ธ
This project is licensed under the MIT License. Feel free to use, modify, and distribute the script as you like.
