Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save joshjm/69dcef304386e928c10c9534c73c3a04 to your computer and use it in GitHub Desktop.
Save joshjm/69dcef304386e928c10c9534c73c3a04 to your computer and use it in GitHub Desktop.

How to make a 1 click connect to bluetooth device button

image

making a shortcut

  • Install Bluetooth Command Line Tools
  • you can use the command line tools to display all device ids by simply running btdiscovery
  • Create a Connect batch script:
	btcom -r -b aa:bb:cc:dd:ee:ff -s110b
	btcom -c -b aa:bb:cc:dd:ee:ff -s110b
  • Create a Disconnect batch script:
	btcom -r -b aa:bb:cc:dd:ee:ff -s110b
  • Open Task Scheduler and Create Task
  • Select Run whether user is logged on or not and Hidden (This will launch the script in the background so you don't see a command window pop up, or in your taskbar)
  • Select Run with the highest privileges
  • From Actions tab, select your Connect batch script
  • Save and enter your password
  • Do the same as above for Disconnect, but Run with the highest privileges is not required.
  • Now create a new shortcut for Connect and Disconnect
  • For Target enter C:\Windows\System32\schtasks.exe /run /tn "Name of your Connect/Disconnect Task"
  • Add custom icons to the shortcuts if you like

Adding to start menu

You have two options:

  • Move shortcuts to C:\ProgramData\Microsoft\Windows\Start Menu\Programs
  • Pin to start menu

other

credit to /u/howheels on reddit

@Reverend-Jim
Copy link

Connect works great. Disconnect does nothing. I'm trying to connect/disconnect to an audio device (hearing aids).

@Alistair1231
Copy link

Alistair1231 commented Oct 22, 2023

Install Bluetooth Command Line Tools

For those searching, here is a link:
https://bluetoothinstaller.com/bluetooth-command-line-tools

Also, you can use this AHK script to bind it to a hotkey:
I use Win+C for connect and Win+Shift+C for disconnect. I added the 111e code to make sure I never have the Hands Free Profile enabled, because I don't use the mic and the audio quality is worse. Also, MS Team likes to force you to use the HFP if it is available....

#c::
  Run, %ComSpec% /c btcom.exe -r -b "aa:bb:cc:dd:ee:ff" -s111e , ,Min
  RunWait, %ComSpec% /c btcom.exe -r -b "aa:bb:cc:dd:ee:ff" -s110b , ,Min
  Run, %ComSpec% /c btcom.exe -c -b "aa:bb:cc:dd:ee:ff" -s110b , ,Min
Return 
#+c::
  Run, %ComSpec% /c btcom.exe -r -b "aa:bb:cc:dd:ee:ff" -s111e , ,Min
  Run, %ComSpec% /c btcom.exe -r -b "aa:bb:cc:dd:ee:ff" -s110b , ,Min
Return

@Iaotle
Copy link

Iaotle commented Apr 20, 2024

@Alistair1231 ty for this, works perfectly for me <3

@MKiedrzyn
Copy link

Thanks, very helpful! :)

@oestrogen
Copy link

This works fine, but for me, each of the two btcom commands take 10–15 seconds to run, so it takes about 25 seconds to connect my Airpods. When I'm in a hurry it's faster to open the Bluetooth settings and manually clicking connect. (There connecting takes just a few seconds).

Anyone else with this problem, or even better, a solution?

@Alistair1231
Copy link

Alistair1231 commented Jul 4, 2025

This works fine, but for me, each of the two btcom commands take 10–15 seconds to run, so it takes about 25 seconds to connect my Airpods. When I'm in a hurry it's faster to open the Bluetooth settings and manually clicking connect. (There connecting takes just a few seconds).

Anyone else with this problem, or even better, a solution?

Yeah it is pretty slow, this is because it first tries to disconnect to make sure it always works properly.

As an alternative to connecting to a specific device, you can instead create a hotkey for the bluetooth quick menu from windows.
Essentially you just need to have some way to set a hotkey to execute explorer "ms-actioncenter:controlcenter/bluetooth"

To do that with Autohotkey, save a file as for example bluetooth-quick-menu.ahk with the following content:

; ^ is Ctrl / # is Win / ! is Alt / + is Shift
; Win + K hotkey for Windows Quick-Menu to (dis)connect Bluetooth devices
#k::
  Run, explorer "ms-actioncenter:controlcenter/bluetooth"
Return

When you run this script, it will make a globally usable Hotkey (Win+K) available, that opens the Bluetooth quick-menu when activated.


By default Win+K is a Display Casting quick-menu. I never use this, but maybe you do. In that case, just adapt the Hotkey to for example #+k:: to use Win + Shift + K instead.


You can also make this Script open automatically after you reboot.

  1. Open the "Run" menu e.g. with Win+R
  2. enter shell:startup
  3. press ok / This opens a folder: C:\Users\USER\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup.
  4. Here, you want to add either the ahk file itself, or a shortcut to the file.
  5. It will now start on every boot, as long as you are able to run the file by double clicking it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment