Open or Close an Application When Bluetooth Device Is Connected/Disconnected

This example opens and closes Spotify automatically when Bose NC 700 HP headphones are turned on/off. Discover how you can use Bluetooth as a trigger with Power Automate for Desktop. You can use any Bluetooth device and application.
How It Works

Flow listens for the state of Bluetooth devices using a console application BluetoothDevices.exe. The application will run constantly in a flow loop and when a Bluetooth device state changes (your turn headphones on/off ), then any application is automatically opened or closed.

This example uses Bose NC 700 HP as the default Bluetooth device name and Spotify.exe as the default application name, but you could use any values you like.

  • Line 1: Set BluetoothDeviceName value, default value: Bose NC 700 HP. Open Windows Bluetooth & devices to find your device name (see image below).
  • Line 2: Set ApplicationFileName value, default value: Spotify.exe. This is requires to start the application.
  • Line 3: Set ApplicationProcessName value, default value: Spotify. This is required to close the application.
  • Line 5: Download BluetoothDevices.exe and set the path value. This console application have been developed just for this purpose and it will list all Bluetooth devices and properties in JSON. You can also create an assembly with an .exe extension yourself (see C# Source Code).

Open Spotify

If you don’t have Spotify installed and you would want to test this flow, then you could for example use Windows Calculator instead with following values:

  • ApplicationFileName: calc.exe
  • ApplicationProcessName: CalculatorApp

C# Source Code

You could also compile the executable yourself.

Console application .NET Framework 4.6.1 uses following NuGet packages:

  • 32feet․NET
  • Newtonsoft.Json

using System;
using System.Collections.Generic;
using InTheHand.Net.Sockets;
using Newtonsoft.Json;

namespace BluetoothDevices
    class Program
        static void Main(string[] args)
            BluetoothClient client = new BluetoothClient();
            List items = new List();
            BluetoothDeviceInfo[] devices = client.DiscoverDevices();
            string json = JsonConvert.SerializeObject(devices);

JSON output example:

    "DeviceAddress": {
        "dataString": "182126E12C7EF"
    "DeviceName": "Bose NC 700 HP",
    "ClassOfDevice": {
        "Device": 1093,
        "MajorDevice": 512,
        "Service": 192,
        "Value": 1327334,
        "ValueAsInt32": 1335364
    "Rssi": -2037473489,
    "InstalledServices": ["10130400-2eca-edae-dacc-deaffccacfff"],
    "Connected": true,
    "Remembered": true,
    "Authenticated": true,
    "LastSeen": "2022-05-29T13:26:17.495Z",
    "LastUsed": "2022-05-29T13:26:17.495Z"
PAG Admin
Also See These Flows