🧰 AutoHotkey v2

Battery Status Popup

Ctrl+Alt+B shows a tooltip with the current battery percentage and charging state, read via WMI.

By WindowsScripting.com · 772 B
BatteryStatusPopup.ahk
; ============================================================
; BatteryStatusPopup.ahk
;
; Ctrl+Alt+B shows a tooltip with battery charge percentage and
; charging status, read from WMI (Win32_Battery).
;
; Requirements: AutoHotkey v2 (https://www.autohotkey.com/)
; ============================================================

#Requires AutoHotkey v2.0

^!b::{
    for battery in ComObjGet("winmgmts:").ExecQuery("SELECT EstimatedChargeRemaining, BatteryStatus FROM Win32_Battery") {
        status := battery.BatteryStatus = 2 ? "Charging" : "On battery"
        ToolTip(battery.EstimatedChargeRemaining "% - " status)
        SetTimer(() => ToolTip(), -2500)
        return
    }
    ToolTip("No battery detected (desktop PC?)")
    SetTimer(() => ToolTip(), -2500)
}