Skip to content

Instantly share code, notes, and snippets.

@Trellmor
Created September 13, 2013 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Trellmor/6548709 to your computer and use it in GitHub Desktop.
Save Trellmor/6548709 to your computer and use it in GitHub Desktop.
AutoHotKey mute applications
#NoEnv ;// Recommended for new scripts
#Persistent ;// Recommended for new scripts
SendMode Input ;// Recommended for new scripts
SetTitleMatchMode 2
; Window title of Volume Mixer
VolumeMixer = Lautstärkemixer
;// Set VolumeMute to only silence Media Center
^!M::
;Mute Apps
;Specify multiple apps like this "Hangouts Plugin; Mozilla Firefox"
MuteApps("Hangouts Plugin")
return
MuteApps(apps)
{
global VolumeMixer
;// Open mixer
Run, sndvol
WinWait, % VolumeMixer
;// Mute Apps
loop, Parse, apps, ";", %A_Space%%A_Tab%
{
appName = %A_LoopField%
MuteApp(appName)
}
;// Close mixer
WinClose, % VolumeMixer
}
;// Volume Mixer must exist
MuteApp(appName)
{
global VolumeMixer
;// Find X position & width of textblock with text matching our appName
ControlGetPos, refX, , refW, , % appName, % VolumeMixer
;// Find button with left side within the width of the textblockµ
x = -1
while ( x != "")
{
;// A_Index is current loop iteration→used to find id
tbIDX := (A_Index * 2)
ControlGetPos, x, , , , ToolbarWindow32%tbIDX%, % VolumeMixer
diff := x - refX
if (diff > 0 && diff < refW)
{
;// msgbox diff: %diff% refX: %refX% tbIDX: %tbIDX% x: %x% A_Index: %A_Index%
ControlClick, ToolbarWindow32%tbIDX%, % VolumeMixer
break
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment