Detect if headphones are plugged in or not via VBScript
Asked Answered
P

1

6

Is any a way to detect if headphones are plugged in or not via VBScript?

This link doesnt help Switching current active sound device using VBScript?

Polyphemus answered 23/11, 2015 at 13:45 Comment(0)
G
2

You should be able to use the Win32_SoundDevice WMI class. Here is a sample 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 comparison runs before and after plugging in your headphones and go from there.

Grasp answered 9/12, 2016 at 22:26 Comment(1)
just wanted to add a link to the official documentation for Win32_SoundDevicePlywood

© 2022 - 2024 — McMap. All rights reserved.