Script that toggles mute on hover Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Net777infamous
Posts: 11
Joined: 18 Nov 2022, 09:42

Script that toggles mute on hover

Post by Net777infamous » 24 Nov 2022, 16:23

Code: Select all

#Persistent
SetTimer, Check, 200
Check:
last := proc, proc := mouseOver()
If (proc != last && proc = "vlc")
Run X:\mute.vbs
Return

mouseOver() {
 MouseGetPos,,, uid
 WinGet, proc, ProcessName, ahk_id %uid%
 Return StrReplace(proc, ".exe")
}
This script toggles mute when I hover over VLC media player. It works perfectly fine, but my only issue is that I have to always move the cursor in and out the window to mute and unmute. Is there anyway to automatically mute when outside the window and unmute when inside.


Thanks in advance!

User avatar
mikeyww
Posts: 27096
Joined: 09 Sep 2014, 18:38

Re: Script that toggles mute on hover  Topic is solved

Post by mikeyww » 24 Nov 2022, 17:41

Code: Select all

#Persistent
SetTimer, Check, 200
Check:
last := proc
MouseGetPos,,, uid
WinGet, proc, ProcessName, ahk_id %uid%
If ((last = "vlc.exe") ^ (proc = "vlc.exe"))
 SoundSet, proc = "vlc.exe" ? False : True,, Mute
Return

Net777infamous
Posts: 11
Joined: 18 Nov 2022, 09:42

Re: Script that toggles mute on hover

Post by Net777infamous » 24 Nov 2022, 17:59

@mikeyww
can't thank you enough. I'm wondering if there's a way to only mute a specific sound device and not the system/master volume. My vlc audio is routed to 'Line-in' and I'd just like to toggle mute that on hover.

User avatar
mikeyww
Posts: 27096
Joined: 09 Sep 2014, 18:38

Re: Script that toggles mute on hover

Post by mikeyww » 24 Nov 2022, 19:31

You could always try setting the ComponentType. :arrow: SoundSet

Net777infamous
Posts: 11
Joined: 18 Nov 2022, 09:42

Re: Script that toggles mute on hover

Post by Net777infamous » 24 Nov 2022, 19:54

Code: Select all

#Persistent
SetTimer, Check, 200
Check:
last := proc
MouseGetPos,,, uid
WinGet, proc, ProcessName, ahk_id %uid%
If ((last = "vlc.exe") ^ (proc = "vlc.exe"))
 SoundSet, , Line proc = "vlc.exe" ? False : True,, Mute
Return
Something like this? Tried it, and it didn't work

Net777infamous
Posts: 11
Joined: 18 Nov 2022, 09:42

Re: Script that toggles mute on hover

Post by Net777infamous » 24 Nov 2022, 19:55

@mikeyww

User avatar
mikeyww
Posts: 27096
Joined: 09 Sep 2014, 18:38

Re: Script that toggles mute on hover

Post by mikeyww » 24 Nov 2022, 22:41

Worth a try:

Code: Select all

#Persistent
componentType = Line
; componentType = Master
controlType   = Mute
SetTimer, Check, 200
Check:
last := proc
MouseGetPos,,, uid
WinGet, proc, ProcessName, ahk_id %uid%
If ((last = "vlc.exe") ^ (proc = "vlc.exe")) {
 newSetting := proc != "vlc.exe"
 SoundSet, %newSetting%, %componentType%, %controlType%
}
Return

Net777infamous
Posts: 11
Joined: 18 Nov 2022, 09:42

Re: Script that toggles mute on hover

Post by Net777infamous » 27 Nov 2022, 15:04

@mikeyww
Using the Soundcard analysis script, I managed to get a list of all component types on my pc. Strangely enough Line in isn't named LINE but Master and on Mixer 10. There are more than 18 Masters on the list and I've tried doing "Master:1" Master:2" and so forth but to no avail.

User avatar
mikeyww
Posts: 27096
Joined: 09 Sep 2014, 18:38

Re: Script that toggles mute on hover

Post by mikeyww » 27 Nov 2022, 16:52

From your first post, it looks like you may have already set up a VBS script that works. There is also an AHK script with some handy functions. https://www.autohotkey.com/board/topic/21984-vista-audio-control-functions/

Post Reply

Return to “Ask for Help (v1)”