Detect if headphones are connected or not via VBScript

Is there a way to detect if the headphones are connected or not through VBScript?

Does this link not help Switch current active sound device using VBScript?

+5
source share
1 answer

You can use the Win32_SoundDevice WMI class. Here is an example script that might be a good starting point:

 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 )

I would do some comparative runs before and after connecting the headphones and from there.

+2
source

Source: https://habr.com/ru/post/1236620/


All Articles