1

I'm new to programming and as a first exercise I wanted to write a program that would mute the volume when the taskbar displays an element with a certain name.

Full disclosure, this is to mute out the ads on Spotify when they come on. I noticed the name of the tab changes to "Spotify - Spotify". When this happens, I'd like the program to mute the volume until the name changes again. Granted I could simply pay the (quite low) monthly subscription, I really wouldn't learn anything from a programming standpoint.

Can anyone point me in the right direction to get started on this?

I've already found this on SO but not exactly what I'm looking for (I think): How to control Windows system volume using JScript or VBScript?

Thanks all.

Community
  • 1
  • 1
EmptyWolf
  • 93
  • 7
  • This is very ambitious for a vbs script. I assume you would only want to mute spotify not all of windows? If so I fear vbscript is not capeable of that. Muting the whole system should be possible the way you found. – Syberdoor Aug 26 '15 at 06:30
  • Thanks Syberdoor! Actually, I'd be fine with the whole system being momentarily muted. If vbs isn't the way to go for such a script, can you please suggest a more adapted language maybe? Thanks again. – EmptyWolf Aug 26 '15 at 07:00
  • well hard to say. If it has to be scripting it would need to be powershell... but the solution would then include basically c# code that imports the windows api so I would not really say this is a nice way to do that either. – Syberdoor Aug 26 '15 at 07:14

1 Answers1

1

If you are ok with muting everything you could try to get all the tasks via the word object (i know...) as described here:

Set objWord = CreateObject("Word.Application")
Set colTasks = objWord.Tasks

For Each objTask in colTasks
    If objTask.Visible Then
        Wscript.Echo objTask.Name
    End If
Next

objWord.Quit

You could put the inner for in a loop and check objTask.Name for "Spotify - Spotify" every second and sleep in between. If you find it you can use the sendkeys solution from the post you already found

var oShell = new ActiveXObject("WScript.Shell");
oShell.SendKeys(String.fromCharCode(0xAD));

to mute the whole system.

Syberdoor
  • 2,521
  • 1
  • 11
  • 14