Skip to content

Latest commit

ย 

History

48 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽง BluetoothDeviceConnector

BluetoothDeviceConnector
AutoHotkey Windows Bluetooth

Platform MIT License Version Downloads Stars

GitHub Sponsors Ko-fi Buy Me a Coffee PayPal

๐Ÿ”— BluetoothDeviceConnector is an AutoHotkey script that connects or disconnects a paired Bluetooth audio device with either stereo-only playback or stereo plus microphone support.

โœจ Features

  • 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!

๐ŸŽฎ Stream Deck Plugin

This project includes an official Stream Deck plugin that lets you connect your Bluetooth devices with a single button press!

Quick Start

  1. Install directly from the Elgato Marketplace or download from GitHub Releases
  2. Add the "Connect Bluetooth Device" action to your Stream Deck
  3. Pick your device and audio profile, then connect with one press!

Features

  • โœ… 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

๐Ÿ› ๏ธ Requirements

  • 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.

๐Ÿš€ How to Use

  1. Install AutoHotkey v2: Make sure AutoHotkey v2 is installed.
  2. Copy the code: Copy the script code into bluetooth_device_connector.ahk.
  3. Run the script: Double-click the .ahk file to run the script.

โš™๏ธ Configuration

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-hfp

๐Ÿง  How It Works

The 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.

๐Ÿ”” Notifications

The script will display notifications in case of:

  • No Bluetooth device found.
  • Device successfully connected or disconnected.
  • Invalid action or audio-profile configuration.

โš ๏ธ Limitations

  • 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.

๐Ÿ› ๏ธ Customization

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

Contributions and improvements are welcome! Feel free to submit a pull request or report any issues on GitHub.

๐Ÿ’– Support the Project

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!

GitHub Sponsors Ko-fi Buy Me a Coffee PayPal

Every contribution, no matter how small, is greatly appreciated! โค๏ธ

๐Ÿ“œ License

This project is licensed under the MIT License. Feel free to use, modify, and distribute the script as you like.

Made with โค๏ธ by Giovanni Guarino

About

Connect and disconnect Bluetooth devices on Windows with a single press: headphones, speakers, and mics, without digging through Windows settings. Available both as a standalone AutoHotkey v2 script and as an Elgato Stream Deck plugin.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

15 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages