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).
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:
C# Source Code
You could also compile the executable yourself.
Console application .NET Framework 4.6.1 uses following NuGet packages:
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:
"DeviceName": "Bose NC 700 HP",