通过 VBScript 检测耳机是否插入

Detect if headphones are plugged in or not via VBScript

有没有办法通过 VBScript 检测耳机是否插入?

这个link没用Switching current active sound device using VBScript?

您应该能够使用 Win32_SoundDevice WMI class。这是一个示例脚本,可能是一个很好的起点:

strComputer = "."
Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_SoundDevice",,48)
For Each objItem in colItems
    Wscript.Echo "Availability: " & objItem.Availability
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Status: " & objItem.Status
    Wscript.Echo "StatusInfo: " & objItem.StatusInfo
Next

(source)

我会在插入耳机之前和之后做一些比较运行,然后从那里开始。