Code: Select all
muteOverride:= 0 ; variable used to integrate hotkey override into automatic commercial muting script (see below for explanation)
#Persistent
SetTimer, CommCheck, 3000 ; check every 3 seconds
Return
CommCheck:
IfWinExist, ahk_exe iexplore.exe
{
CoordMode, Pixel, Screen
ImageSearch, X, Y, -1620, -850, -330, -780, *20, %commercial1Path% ; imagesearch for image 1
if ErrorLevel = 0
{
RunWait, D:\Downloads\nircmd\nircmd.exe muteappvolume iexplore.exe 1 ; mute
muteOverride := 0
}
else if ErrorLevel = 1
{
CoordMode, Pixel, Screen
ImageSearch, X, Y, -1620, -850, -1450, -185, *20, %commercial2Path% ; ; imagesearch for image 2
if ErrorLevel = 0
{
RunWait, D:\Downloads\nircmd\nircmd.exe muteappvolume iexplore.exe 1 ; mute
muteOverride := 0
}
else if (ErrorLevel = 1) && (muteOverride = 0)
{
RunWait, D:\Downloads\nircmd\nircmd.exe muteappvolume iexplore.exe 0 ; unmute
}
}
else if ErrorLevel = 2
MsgBox problem with imagesearch
}
Return
Code: Select all
!+c:: ;toggles mute/unmute for IE
IfWinExist, ahk_exe iexplore.exe
RunWait, D:\Downloads\nircmd\nircmd.exe muteappvolume iexplore.exe 2 ; toggle mute/unmute
if muteOverride = 0
{
muteOverride := 1
}
else if muteOverride = 1
{
muteOverride := 0
}
return
On a side note, I understand the need for commercials, and I wouldn't have bothered to write this script but for the obnoxious and jarring volume increases for the commercials (i.e., programmed content plays at one volume, commercials play at a higher volume). And since I was writing the script, it was just as easy to mute as it was to lower volume.