Android和iOS阵营都有给设备充电的提示音, 但是Windows没有, 感觉少了点仪式感. 所以就想着给Windows也加一个充电提示音.@2021/09/12 更新重新组织了一下代码, 修复了将充满识别成断开电源的问题.\#0 获取充电状态第一反应是通过Windows日志获取电源状态更改事件, 然后用计划任务去播放声音.结果实际测试下来这种方法延迟很高(约5秒), 体验不大行, 所以直接使用VBScript去实现查询.我也不知道为什么要这样实现, 四处搜刮得到的代码, 能用就行.pngSet WMI = GetObject("winmgmts:\\.\root\WMI") Dim LastState Function GetCharge Set Query = WMI.ExecQuery("Select PowerOnline From BatteryStatus") For Each Status In Query If Status.PowerOnline <> LastState Then GetCharge = Status.PowerOnline Exit Function End If Next GetCharge = LastState End Function LastState = GetCharge While True Current = GetCharge If Current <> LastState Then If Current Then PlaySound("charge") Else PlaySound("discharge") End If LastState = Current End If WScript.Sleep 500 Wend\#1 播放声音然后cv一个播放声音的代码:Set Fs = CreateObject("Scripting.FileSystemObject") Set Player = CreateObject("WMPlayer.OCX") Function PlaySound(name) Path = "./"+ name +".mp3" If (Not Fs.FileExists(Path)) Then Exit Function End If Player.URL = Path Player.Controls.play End Function\#2 找点音效素材从几个不知名的国外网站上面凑齐了一套MIUI的充电音效:连接充电器:草了, 2021年了, 你的浏览器怎么还不支持HTML5断开充电器:草了, 2021年了, 你的浏览器怎么还不支持HTML5\#3 拼接一下代码Set Fs = CreateObject("Scripting.FileSystemObject") Set Player = CreateObject("WMPlayer.OCX") Set WMI = GetObject("winmgmts:\\.\root\WMI") Dim LastState Function PlaySound(name) Path = "./"+ name +".mp3" If (Not Fs.FileExists(Path)) Then Exit Function End If Player.URL = Path Player.Controls.play End Function Function GetCharge Set Query = WMI.ExecQuery("Select PowerOnline From BatteryStatus") For Each Status In Query If Status.PowerOnline <> LastState Then GetCharge = Status.PowerOnline Exit Function End If Next GetCharge = LastState End Function LastState = GetCharge While True Current = GetCharge If Current <> LastState Then If Current Then PlaySound("charge") Else PlaySound("discharge") End If LastState = Current End If WScript.Sleep 500 Wend\#4 开机启动计划任务就行, 就像这样:<?xml version="1.0" encoding="UTF-16"?> 2021-09-09T11:35:11.9499057 Zapic Play notify sound when charger connected or discconected. \ChargeNotify true S-1-5-18 LeastPrivilege <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy> <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries> <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries> true true <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable> true false true true false false false PT0S 7 C:\Windows\ChargeNotify\daemon.vbs C:\Windows\ChargeNotify\ \#5 试一下草了, 2021年了, 你的浏览器怎么还不支持HTML5所有结果都在这个压缩包里了：ChargeNotify.zip (36.6KiB)把整个文件夹放到C:\Windows\下, 然后把文件夹里的ChargeNotify.xml作为计划任务导入即可.