I would like to emulated with a shortcut the process of 1) opening the Action Center and 2) clicking on the bluetooth icon.

My solution was to use AHK to map a keyboard shortcut to running a .bat, which contains the script suggested in this question.

But the suggested service doesn't activate/remove the magic little blue icon of the bluetooth in the tray bar.enter image description here

I have look for all bluetooth services that are turned on when I click on the bluetooth icon in action center and I have activated them via the suggested .bat, but still it's not working.


Here are all the services: enter image description here enter image description here

My script (where I have replace Microsoft_Bluetooth_AvrcpTransport by all the service mentionned above):

@echo off

for /F "tokens=3 delims=: " %%H in ('sc query "Microsoft_Bluetooth_AvrcpTransport" ^| findstr "STATE"') do (
  if /I "%%H" NEQ "RUNNING" (
   net start "Microsoft_Bluetooth_AvrcpTransport"
  ) else if /I "%%H" NEQ "STOPPED" (
   net stop "Microsoft_Bluetooth_AvrcpTransport"


You don't need to stop/start these services for getting rid of the Bluetooth traybar icon.

The display of the icon is controlled in the registry key HKEY_CURRENT_USER\Control Panel\Bluetooth, by the DWORD value Notification Area Icon whose value is 0 for Off and 1 for On. This requires restarting Explorer to take effect.

The following two .bat files will do the job.

Disable the Bluetooth notification area icon

REG ADD "HKCU\Control Panel\Bluetooth" /V "Notification Area Icon" /T REG_DWORD /D 00000000 /F
taskkill /f /im explorer.exe
start explorer.exe

Enable the Bluetooth notification area icon

REG ADD "HKCU\Control Panel\Bluetooth" /V "Notification Area Icon" /T REG_DWORD /D 00000001 /F
taskkill /f /im explorer.exe
start explorer.exe
  • Sorry I was clear enough, I do not want to get rid of the blue bluetooth icon, I want to start /stop the bluetooth, and when the bluetooth is on I want the blue icon, and when the bluetooth is stopped (and only then) I do not want the blue icon. – MagTun Oct 21 at 16:01
  • What was wrong with the post in a comment above? – harrymc Oct 21 at 18:29
  • The answer in the post works but I have some difficulties to adapt it so I can use it with a shortcut : superuser.com/questions/1494499 – MagTun Oct 22 at 5:10
  • If that script works, the AutoHotKey command can be improved as Run, powershell C:\path\to\bluetooth.ps1 On and another shortcut for Off. – harrymc Oct 22 at 9:15
  • Yes, I could do that (which I am already doing) but I would like to use just one shortcut. – MagTun Oct 22 at 16:13

First create an .ahk shortcut that starts a powershell:

Run, C:\Users\user\Desktop\bluetooth.ps1,,Hide 

Then you create a powershell:

If ((Get-Service bthserv).Status -eq 'Stopped') { Start-Service bthserv }
Add-Type -AssemblyName System.Runtime.WindowsRuntime
$asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0]
Function Await($WinRtTask, $ResultType) {
    $asTask = $asTaskGeneric.MakeGenericMethod($ResultType)
    $netTask = $asTask.Invoke($null, @($WinRtTask))
    $netTask.Wait(-1) | Out-Null
[Windows.Devices.Radios.Radio,Windows.System.Devices,ContentType=WindowsRuntime] | Out-Null
[Windows.Devices.Radios.RadioAccessStatus,Windows.System.Devices,ContentType=WindowsRuntime] | Out-Null
Await ([Windows.Devices.Radios.Radio]::RequestAccessAsync()) ([Windows.Devices.Radios.RadioAccessStatus]) | Out-Null
$radios = Await ([Windows.Devices.Radios.Radio]::GetRadiosAsync()) ([System.Collections.Generic.IReadOnlyList[Windows.Devices.Radios.Radio]])
$bluetooth = $radios | ? { $_.Kind -eq 'Bluetooth' }
[Windows.Devices.Radios.RadioState,Windows.System.Devices,ContentType=WindowsRuntime] | Out-Null
if ($bluetooth.state -eq 'On') {$BluetoothStatus = 'Off'} else {$BluetoothStatus = 'On'}
Await ($bluetooth.SetStateAsync($BluetoothStatus)) ([Windows.Devices.Radios.RadioAccessStatus]) | Out-Null

All credit goes to @Ben N and @Scott Heath

This script works when I launch it from VScode, when I copy-paste it in a powershell, or when I use a cmd to start it. But not when I double-click it or when I start it in .ahk. The work around was to create a .bat file with this

Run, C:\Users\user\Desktop\bluetooth.ps1,,Hide

And then call this .bat in ahk.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.