Auto unmute a specific program upon launching this program

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
WilliamLeGod
Posts: 8
Joined: 01 May 2024, 18:52

Auto unmute a specific program upon launching this program

01 May 2024, 18:57

Hi guys!

Does any1 know a script (run in background all the time) that auto unmute a specific program upon launching this program?

Many thanks!
User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Auto unmute a specific program upon launching this program

04 May 2024, 02:21

It’s very specific to the program, and you haven’t provided any details. How do you manually unmute it? Is there a keyboard shortcut?
WilliamLeGod
Posts: 8
Joined: 01 May 2024, 18:52

Re: Auto unmute a specific program upon launching this program

04 May 2024, 03:28

boiler wrote:
04 May 2024, 02:21
It’s very specific to the program, and you haven’t provided any details. How do you manually unmute it? Is there a keyboard shortcut?
Hi! Thanks for the help

So there is no keyboard shortcut required. I think about a script that has Programlist: A.exe, B.exe ... And with this script runs in background, whenever program A or B starts, immediately unmute that program and thats it!

Appreciate your time!
User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Auto unmute a specific program upon launching this program

04 May 2024, 03:47

No, you’re not understanding what I’m saying. I’m not saying the script would create a shortcut. I’m asking you to describe how you manually unmute the program(s) so that the script can mimic those actions, such as sending whatever keyboard shortcut that program may have built in for muting and unmuting. You have given us no info with which we can help you.
WilliamLeGod
Posts: 8
Joined: 01 May 2024, 18:52

Re: Auto unmute a specific program upon launching this program

04 May 2024, 03:58

boiler wrote:
04 May 2024, 03:47
No, you’re not understanding what I’m saying. I’m not saying the script would create a shortcut. I’m asking you to describe how you manually unmute the program(s) so that the script can mimic those actions, such as sending whatever keyboard shortcut that program may have built in for muting and unmuting. You have given us no info with which we can help you.
got it!
I mute the program using this ahk https://github.com/TomiBelan/mute-on-focus-lost
Using this ahk, I don't know why the next time I start any program, it just auto mutes so Im thinking of another ahk to unmute to make it perfect!
User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Auto unmute a specific program upon launching this program

04 May 2024, 05:00

From what I see, that script doesn’t mute a specific program, but it turns the master volume for your computer to zero, muting everything. It may be triggered by a certain program’s window losing focus, but at first glance, it looks like it’s not doing anything to mute only that program. Is that right?
XMCQCX
Posts: 285
Joined: 14 Oct 2020, 23:44

Re: Auto unmute a specific program upon launching this program

04 May 2024, 05:59

If you want to unmute specific windows when they're activated and mute them when they're deactivated, you can try my script, WinExeCommander. Create events for active windows and call these functions. You'll need Nircmd and changing the path accordingly.

Code: Select all

Mute_Unmute_Created(mEvent) => Run('D:\Programmes\Nircmd\nircmd.exe muteappvolume ' mEvent['processName'] ' 0')

Mute_Unmute_Terminated(mEvent) => Run('D:\Programmes\Nircmd\nircmd.exe muteappvolume ' mEvent['processName'] ' 1')
WilliamLeGod
Posts: 8
Joined: 01 May 2024, 18:52

Re: Auto unmute a specific program upon launching this program

04 May 2024, 08:36

boiler wrote:
04 May 2024, 05:00
From what I see, that script doesn’t mute a specific program, but it turns the master volume for your computer to zero, muting everything. It may be triggered by a certain program’s window losing focus, but at first glance, it looks like it’s not doing anything to mute only that program. Is that right?
Yes you are right, and I noticed a bug that many programs affected by that script, the next time I boot it up, the sound just mute on default so I need to find a nother script to unmute that program
WilliamLeGod
Posts: 8
Joined: 01 May 2024, 18:52

Re: Auto unmute a specific program upon launching this program

04 May 2024, 08:38

XMCQCX wrote:
04 May 2024, 05:59
If you want to unmute specific windows when they're activated and mute them when they're deactivated, you can try my script, WinExeCommander. Create events for active windows and call these functions. You'll need Nircmd and changing the path accordingly.

Code: Select all

Mute_Unmute_Created(mEvent) => Run('D:\Programmes\Nircmd\nircmd.exe muteappvolume ' mEvent['processName'] ' 0')

Mute_Unmute_Terminated(mEvent) => Run('D:\Programmes\Nircmd\nircmd.exe muteappvolume ' mEvent['processName'] ' 1')
Thanks for the help bro!
Can I add multiple processname to it and how will the code be like?
WilliamLeGod
Posts: 8
Joined: 01 May 2024, 18:52

Re: Auto unmute a specific program upon launching this program

05 May 2024, 01:42

Code: Select all

Mute_Unmute_Created(mEvent) {

    if WinExist('ff7remake_ ' mEvent['ff7remake_'])
     Run('H:\Playnite\Console\Mute on Focus\nircmd.exe muteappvolume ' mEvent['ff7remake_'] ' 0')
   }
I pasted this into WinExeCommander.ahk
I tried this but it didnt unmute Ff7 upon launching. Am I missing something?

[Mod edit: Added [code][/code] tags. Please use them yourself when posting code!]
XMCQCX
Posts: 285
Joined: 14 Oct 2020, 23:44

Re: Auto unmute a specific program upon launching this program

05 May 2024, 03:51

@WilliamLeGod
Like that.

Code: Select all

Mute_Unmute_Created(mEvent) {

    Run('H:\Playnite\Console\Mute on Focus\nircmd.exe muteappvolume ' mEvent['processName'] ' 0')
}
Make sure the function name associated with the event is "Mute_Unmute". Can you make the "Calculator_AlwaysOnTop" example function properly?
WilliamLeGod
Posts: 8
Joined: 01 May 2024, 18:52

Re: Auto unmute a specific program upon launching this program

05 May 2024, 09:27

I just tested Calculator script but it didn't work.
XMCQCX
Posts: 285
Joined: 14 Oct 2020, 23:44

Re: Auto unmute a specific program upon launching this program

05 May 2024, 12:51

@WilliamLeGod
1- Delete everything from "WinExeCommander.ahk", paste this and save:

Code: Select all

#Requires AutoHotkey v2.0
#SingleInstance

#Include '.\Lib\WinExeCmd.ahk'


Calculator_AlwaysOnTop_Created(mEvent) {
    
    if WinExist('ahk_id ' mEvent['id'])
        WinSetAlwaysOnTop(1, 'ahk_id ' mEvent['id'])
    else
        WinExeCmd.MsgBox('Calculator does not exist.', 'WinExeCommander', 'iconx')    
}

;==============================================

Unmute_Created(mEvent) {

    Run('H:\Playnite\Console\Mute on Focus\nircmd.exe muteappvolume ' mEvent['processName'] ' 0')
}
2- Delete everything from "Settings.json", paste this and save:

Code: Select all

{
  "mEvents":{
    "Calculator_AlwaysOnTop":{
      "critical":0,
      "function":"Calculator_AlwaysOnTop",
      "log":0,
      "mode":"2",
      "monitoring":"winEvent",
      "notifInfo":0,
      "notifStatus":1,
      "period":"1000",
      "soundCreated":"- None -",
      "soundTerminated":"- None -",
      "state":1,
      "window":{
        "detectHiddenWindows":0,
        "processName":"ApplicationFrameHost.exe",
        "processPath":"C:\\Windows\\System32\\ApplicationFrameHost.exe",
        "winActive":0,
        "winClass":"ApplicationFrameWindow",
        "winMinMax":"",
        "winTitle":"Calculator",
        "winTitleMatchMode":"2"
      }
    },
    "ff7remake_Unmute":{
      "critical":0,
      "function":"Unmute",
      "log":0,
      "mode":"2",
      "monitoring":"winEvent",
      "notifInfo":0,
      "notifStatus":1,
      "period":"1000",
      "soundCreated":"- None -",
      "soundTerminated":"- None -",
      "state":1,
      "window":{
        "detectHiddenWindows":0,
        "processName":"ff7remake_.exe",
        "processPath":"",
        "winActive":0,
        "winClass":"",
        "winMinMax":"",
        "winTitle":"",
        "winTitleMatchMode":"2"
      }
    }
  },
  "mUser":{
    "alwaysOnTop":0,
    "critical":0,
    "delayDeviceChange":1250,
    "delayWinEvent":1000,
    "detectHiddenWindows":0,
    "dwFlagsWinEvent":"0x0",
    "log":0,
    "mWinEventsStates":{
      "EVENT_SYSTEM_ALERT":0,
      "EVENT_SYSTEM_CAPTUREEND":1,
      "EVENT_SYSTEM_CAPTURESTART":1,
      "EVENT_SYSTEM_CONTEXTHELPEND":0,
      "EVENT_SYSTEM_CONTEXTHELPSTART":0,
      "EVENT_SYSTEM_DIALOGEND":1,
      "EVENT_SYSTEM_DIALOGSTART":1,
      "EVENT_SYSTEM_DRAGDROPEND":0,
      "EVENT_SYSTEM_DRAGDROPSTART":0,
      "EVENT_SYSTEM_FOREGROUND":1,
      "EVENT_SYSTEM_MENUEND":0,
      "EVENT_SYSTEM_MENUPOPUPEND":0,
      "EVENT_SYSTEM_MENUPOPUPSTART":0,
      "EVENT_SYSTEM_MENUSTART":0,
      "EVENT_SYSTEM_MINIMIZEEND":1,
      "EVENT_SYSTEM_MINIMIZESTART":1,
      "EVENT_SYSTEM_MOVESIZEEND":0,
      "EVENT_SYSTEM_MOVESIZESTART":0,
      "EVENT_SYSTEM_SCROLLINGEND":0,
      "EVENT_SYSTEM_SCROLLINGSTART":0,
      "EVENT_SYSTEM_SOUND":0,
      "EVENT_SYSTEM_SWITCHEND":1,
      "EVENT_SYSTEM_SWITCHSTART":1
    },
    "modeDevice":2,
    "modeProcess":2,
    "modeWindow":2,
    "monitoringDevice":"deviceChange",
    "monitoringProcess":"wmi",
    "monitoringWindow":"winEvent",
    "notifInfo":1,
    "notifProfileMatch":1,
    "notifProfileStart":1,
    "notifStatus":1,
    "periodTimerDevice":1500,
    "periodTimerProcess":1500,
    "periodTimerWindow":1500,
    "periodWMIprocess":1250,
    "profileLoadEvent":0,
    "soundCreated":"- None -",
    "soundProfile":"- None -",
    "soundTerminated":"- None -",
    "state":0,
    "themeName":"Reptilian",
    "trayIconLeftClick":"- None -",
    "trayIconLeftDClick":"Open Events Manager",
    "trayMenuIconSize":20,
    "winActive":0,
    "winEventPreset":3,
    "winMinMax":"",
    "winTitleMatchMode":2
  }
}
3- Reload the script if it's currently running. If it's not running, double-click on WinExeCommander.ahk to launch it.

4- Open the Calculator app.

If it doesn't work, you can try other methods suggested in this tutorial to detect window open and close.

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: boardtc, DavidP, Draken and 33 guests