Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Mute a specific progra


  • Please log in to reply
10 replies to this topic
austin6598
  • Members
  • 4 posts
  • Last active: May 24 2015 11:04 PM
  • Joined: 06 Sep 2013

I just installed ahk, I simply need it to do one thing. I was wondering if there was some way to mute the sound in a program just from pressing a key. The program I want to toggle to a mute key  for is called "Deskscapes". 

 

I would really appreciate the help!



lifeweaver
  • Members
  • 868 posts
  • Last active: Jan 25 2016 01:29 AM
  • Joined: 04 Mar 2013
Hi austin6598,
 
You might try using the VA.ahk audio library and the the function from this post. i.e. change 'if !(Volume := GetVolumeObject(""))' to 'if !(Volume := GetVolumeObject("your app name here"))'
 
Disclaimer: When looking at my volume mixer I could see the 'Mute' icon switch to mute but could still here sound, however I'm using an optical sound out so I don't know if that makes a difference.
 
Here is what I used:
Spoiler

My script runs in A_AhkVersion:=1.1.22.07, get the latest version at http://ahkscript.org/download/

Check out this AutoHotkey tutorial: http://ahkscript.git...o/AHK_Tutorial/

Read the documentation: http://ahkscript.org.../AutoHotkey.htm


Menixator
  • Members
  • 744 posts
  • Last active: Sep 01 2015 02:54 PM
  • Joined: 10 Jul 2013

Lifeweaver, Do you happen to know how to retrieve the volume? I tweaked around and found how to set the volume but not to retrieve the volume.



lifeweaver
  • Members
  • 868 posts
  • Last active: Jan 25 2016 01:29 AM
  • Joined: 04 Mar 2013

@Menixator, I set my volumes at different levels for each device then used this script so I knew which number corresponds to which volume.

Loop 10
{
  this_test := VA_GetMasterVolume("", A_Index)
  msgbox Device %A_Index% Volume == %this_Test%
}

Once you know the number you need you can do something like:

myVolume := VA_GetMasterVolume("", 3)

My script runs in A_AhkVersion:=1.1.22.07, get the latest version at http://ahkscript.org/download/

Check out this AutoHotkey tutorial: http://ahkscript.git...o/AHK_Tutorial/

Read the documentation: http://ahkscript.org.../AutoHotkey.htm


austin6598
  • Members
  • 4 posts
  • Last active: May 24 2015 11:04 PM
  • Joined: 06 Sep 2013

guys I am 100% noob. I have no clue how to insert this code into ahk. Please help me and where do I put the program name exactly?



lifeweaver
  • Members
  • 868 posts
  • Last active: Jan 25 2016 01:29 AM
  • Joined: 04 Mar 2013

Hi austin6598, No problem.

 

First have you tried to follow the tutorial?  I know you said "all I want to do" but it would help you greatly.

 

Steps you need to take:

  1. Go here and download the 'VA.ahk' file, extract it, and put it in your Lib folder.
    1. The lib folder is where you store supporting scripts/libraries of code, read here to learn about the libraries.
    2. Generally you have a lib folder somewhere like My Documents/AutoHotkey/Lib
  2. Next create an AutoHotkey script, this can be done by opening a text editor and saving it with the extension .ahk
  3. Take the script I posted above and replace the text 'Windows Media Player' with the name of your application
    1. One of the best ways to get the 'name' of an application is by using windows spy.
    2. The windows spy can be opened by: Start > All Programs > AutoHotkey > AutoIt3 Window Spy.
    3. You then active the application by clicking on it and look at what windows spy shows the title as.
  4. Note: It sounds like your application is different than normal so you might just try replacing 'Windows Media Player' with 'Deskscapes' and see if that works
  5. After you have changed the script to your liking you want to save it and then double click on the script to start it
  6. In the case of this script the hotkey to mute the specified application is Ctrl + m. in the script => ^m::

My script runs in A_AhkVersion:=1.1.22.07, get the latest version at http://ahkscript.org/download/

Check out this AutoHotkey tutorial: http://ahkscript.git...o/AHK_Tutorial/

Read the documentation: http://ahkscript.org.../AutoHotkey.htm


austin6598
  • Members
  • 4 posts
  • Last active: May 24 2015 11:04 PM
  • Joined: 06 Sep 2013

This is EXACTLY what I want! I am just having some trouble. Sorry but I really don't want to read that thing to learn about libraries. So where exactly do you see "Windows Media Player" in your script. I just don't know where to put Descapes in your script. Also I could find the documents folder you requested. I just used the regular "My Documents" instead of Autohotkey/Lib. Will that affect the script? 



lifeweaver
  • Members
  • 868 posts
  • Last active: Jan 25 2016 01:29 AM
  • Joined: 04 Mar 2013

If you click on the button that says 'Spoiler' on my first post it will expand and show the script, inside this is the 'Windows Media Player.

 

At the very least you will need to change the second line '#Include D:\The Vault\AutoHotKey\lib\VA.ahk' to match where you have stored the VA.ahk.

You will also need to change the fourth line 'WinGet, test, PID, Windows Media Player' to match your application.

 

Lastly, this isn't what I'd call a simple script., AutoHotkey is a programming language, easier than some but you still need to put in effort to make it do what you want, that sometimes includes reading the documentation.


My script runs in A_AhkVersion:=1.1.22.07, get the latest version at http://ahkscript.org/download/

Check out this AutoHotkey tutorial: http://ahkscript.git...o/AHK_Tutorial/

Read the documentation: http://ahkscript.org.../AutoHotkey.htm


austin6598
  • Members
  • 4 posts
  • Last active: May 24 2015 11:04 PM
  • Joined: 06 Sep 2013

I know I posted this a long time ago but I never figured it out and I still want to. (The fourth line says "msgbox %test", I think you meant the 3rd line)

 

The VA.ahk line is taken care of

The line that says "WinGet, test, PID, Windows Media Player" confuses me

Do I just replace Windows Media Player or do I have to change the rest of the line?

Heres is a link to the program I am using: http://www.door2wind...indows-7-vista/



lifeweaver
  • Members
  • 868 posts
  • Last active: Jan 25 2016 01:29 AM
  • Joined: 04 Mar 2013

http://www.autohotke...ands/WinGet.htm

 

 

WinGet Homepage
Command List

Retrieves the specified window's unique ID, process ID, process name, or a list of its controls. It can also retrieve a list of all windows matching the specified criteria.

 

WinGet, OutputVar [, Cmd, WinTitle, WinText, ExcludeTitle, ExcludeText]

Parameters OutputVar The name of the variable in which to store the result of Cmd. Cmd See list below. WinTitle The title or partial title of the target window (the matching behavior is determined by SetTitleMatchMode). If this and the other 3 parameters are omitted, the Last Found Window will be used. If this is the letter A and the other 3 window parameters are blank or omitted, the active window will be used. To use a window class, specify ahk_class ExactClassName (shown by Window Spy). To use a process identifier (PID), specify ahk_pid %VarContainingPID%. To use a window's unique ID number, specify ahk_id %VarContainingID%. The search can be narrowed by specifying multiple criteria. For example: My File.txt ahk_pid %VarContainingPID% WinText If present, this parameter must be a substring from a single text element of the target window (as revealed by the included Window Spy utility). Hidden text elements are detected if DetectHiddenText is ON. ExcludeTitle Windows whose titles include this value will not be considered. ExcludeText Windows whose text include this value will not be considered.

Cmd is the operation to perform, which if blank defaults to ID. It can be one of the following words:

 

PID: Retrieves the Process ID (PID) of a window.

 


My script runs in A_AhkVersion:=1.1.22.07, get the latest version at http://ahkscript.org/download/

Check out this AutoHotkey tutorial: http://ahkscript.git...o/AHK_Tutorial/

Read the documentation: http://ahkscript.org.../AutoHotkey.htm


schnoman
  • Members
  • 1 posts
  • Last active: Oct 16 2014 02:19 AM
  • Joined: 08 Oct 2014

Sorry to resurrect an old thread, but I'm having trouble adapting this (be it a Windows 8 thing?).  I can get the functionality working, but it seems to mute only the 'system sounds' application instead of the one I program in to the script (tried with Media Player, Chrome, etc.).

 

I tried using the process name instead of PID for WinGet but same results.  I think it may have something to do with the audio sessions, but can't put my finger on it (sorry, still learning the product after a couple of months).