Bluetooth Device Battery Indicator Display in System Tray

Deepak Vasudevan 96 Reputation points
2023-01-09T02:29:01.6+00:00

When we hover a mouse over the Volume icon in System Tray it currently shows the sound level indicator. Would it be possible to replace with Battery Level indicator (if connected to BlueTooth device) or add it along with Sound Level?

277275-image.png

Windows Hardware Performance
Windows Hardware Performance
Windows: A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.Hardware Performance: Delivering / providing hardware or hardware systems or adjusting / adapting hardware or hardware systems.
1,625 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
9,894 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. RMC 20 Reputation points
    2023-06-26T07:51:27.0966667+00:00

    Hello,

    I have written a PowerShell script to obtain the battery level of my headphone.
    If anyone wants to use it, just remember to follow the instruction on the comments and change the name of your Bluetooth device on variable 'BTDeviceFriendlyName' to the same name that appears assigned to your Bluetooth device.

    The battery level will appear in a windows pop-up dialog. Just read the instruction in the beginning of the script.

    The script also measures the time it takes to execute. I was a bit worried about the time it was taking to execute, so after tweaking and optimizing a little bit, I left it there for the next brave person that can find a way to make it faster ;-)

    BTW, I have only tested with Windows 11, so you may have to adapt or change the value of '$Device.InstanceId' to the correct one according to your system.

    Cheers!

    # ATTENTION: Don't forget to allow the powershell script to run first.
    # Here is a step by step of how to execute this script:
    # - Open a Powershell command prompt. 
    # - Allow shel script execution with command:
    #   Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process
    # - Execute the current powershell script with the command:
    #   .\GetBatteryLevel_DOQAUS-CARE1v1.ps1
    # - The results may take some time to come. A pop-up will show on your 
    #   main screen. You must click 'Ok' to unblock the Powershell command prompt.
    
    $StartTime = Get-Date
    $BTDeviceFriendlyName = "DOQAUS CARE 1"
    $Shell = New-Object -ComObject "WScript.Shell"
    $BTHDevices = Get-PnpDevice -FriendlyName "*$($BTDeviceFriendlyName)*"
    
    if ($BTHDevices) {
        $BatteryLevels = foreach ($Device in $BTHDevices) {
            $BatteryProperty = Get-PnpDeviceProperty -InstanceId $Device.InstanceId -KeyName '{104EA319-6EE2-4701-BD47-8DDBF425BBE5} 2' |
                Where-Object { $_.Type -ne 'Empty' } |
                Select-Object -ExpandProperty Data
    
            if ($BatteryProperty) {
                $BatteryProperty
            }
        }
    
        if ($BatteryLevels) {
    		$ElapsedTime = (Get-Date) - $StartTime
            $ElapsedTimeMilliseconds = [math]::Round($ElapsedTime.TotalMilliseconds, 0)
            $ElapsedTimeStr = "$($ElapsedTimeMilliseconds) ms"
            if ($ElapsedTimeMilliseconds -gt 1000) {
                $ElapsedTimeSeconds = $ElapsedTime.TotalSeconds
                $ElapsedTimeStr = "$($ElapsedTimeSeconds) sec"
            }
            $Message = "Battery Level of $($BTDeviceFriendlyName): $BatteryLevels %`nElapsed Time: $($ElapsedTimeStr)"
            $Button = $Shell.Popup($Message, 0, "Battery Level", 0)
        }
        else {
            Write-Host "No battery level information found for $($BTDeviceFriendlyName) devices."
        }
    }
    else {
        Write-Host "Bluetooth device found."
    }
    
    
    4 people found this answer helpful.

  2. Dmytro Tomayly 10 Reputation points
    2023-10-02T01:46:01.47+00:00

    I am using this tool: https://workstation-master.com/bluetooth-battery-level.html simple and looks like part of the system, check it

    2 people found this answer helpful.

  3. Limitless Technology 44,401 Reputation points
    2023-01-10T09:15:02.95+00:00

    Hello there,

    So you need the battery level of your Bluetooth device right? We cannot get the Battery percentage by hovering but you can get it when you see the connected list.

    1 Open Settings (Win+I). 2 Click/tap on Bluetooth & devices on the left side, and click/tap on Devices on the right side. 3 Look for the battery percentage (if supported ) of your Bluetooth device(s) on the right side.

    You can get information on Bluetooth devices using the Get-PnpDevice cmdlet. This should return a list of PnP Devices, their Status, Class, FriendlyName and InstanceID.

    Get-PnpDevice You can filter the results with -Class parameter. To specify Bluetooth PnP devices, you can enter "Bluetooth" as a string value for the -Class parameter.

    Get-PnpDevice -Class 'Bluetooth'

    Hope this resolves your Query !!

    --If the reply is helpful, please Upvote and Accept it as an answer–

    1 person found this answer helpful.
    0 comments No comments

  4. Sundar Singh 0 Reputation points
    2023-08-03T13:57:48.6133333+00:00

    This worked. Thanks.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.