I tried searching but I can't seem to be find anything besides USB detection. I want to make a script that detects when the speaker and microphone ports has a device plugged in. Is this possible to do? Make the script run (some other stuff) when you plug in a headset for example.
You should be able to invoke a script by running a status query after calling WMI Class Win32_bus Class
Read this page for more clarity : Computer System Hardware Classes