gpt4 book ai didi

Autohotkey - 如何仅调整特定程序的音量?

转载 作者:行者123 更新时间:2023-12-04 20:34:27 24 4
gpt4 key购买 nike

我想控制特定程序的音量,而不是整个主音量。

我找到了 THIS具有用于仅从 Volume Mixer 控制 Windows Media Player 音量的代码的线程。

这是整个脚本:

SetTitleMatchMode, 3
SndVolWasStarted = 0

;Turn off SndVol after 1 second
Loop {
Sleep, 10
If SndVolWasStarted = 1
{
GetKeyState, StateF1, F1
GetKeyState, StateF2, F2
If (StateF1 = "D" or StateF2 = "D")
SndVolStartTime = %A_Now%
Else {
If ((A_Now - SndVolStartTime > 1) and WinExist("ahk_class #32770"))
WinClose, ahk_class #32770
}
IfWinNotExist, ahk_class #32770
SndVolWasStarted = 0
}
}

;Hotkey to decrease volume
F1::
IfWinExist, Windows Media Player
{
IfWinNotExist, ahk_class #32770
{
Run, "%A_WinDir%\System32\SndVol.exe" -r 88888888
WinWait, ahk_class #32770
SndVolWasStarted = 1
}
ToolbarWindowNumber = 322
msctls_trackbarNumber = 321
Loop {
ControlGetText, ControlName, ToolbarWindow%ToolbarWindowNumber%, ahk_class #32770
If ControlName = Mute for Windows Media Player
{
ControlSend, msctls_trackbar%msctls_trackbarNumber%, {Down}, ahk_class #32770 ; Use {Down 2} to change sound level faster
Break
} Else {
If ToolbarWindowNumber < 328
{
ToolbarWindowNumber := ToolbarWindowNumber + 2
msctls_trackbarNumber := msctls_trackbarNumber + 1
} Else {
If ToolbarWindowNumber = 328
{
ToolbarWindowNumber = 3210
msctls_trackbarNumber := msctls_trackbarNumber + 1
} Else {
If ToolbarWindowNumber < 3242
{
ToolbarWindowNumber := ToolbarWindowNumber + 2
msctls_trackbarNumber := msctls_trackbarNumber + 1
} Else {
MsgBox, 16, AutoHotkey, ERROR: Application's volume control was not found!`nThis could occur if the Volume Mixer has more than 20 opened applications
Break
}
}
}
}
}
}
Return

;Hotkey to increase volume
F2::
IfWinExist, Windows Media Player
{
IfWinNotExist, ahk_class #32770
{
Run, "%A_WinDir%\System32\SndVol.exe" -r 88888888
WinWait, ahk_class #32770
SndVolWasStarted = 1
}
ToolbarWindowNumber = 322
msctls_trackbarNumber = 321
Loop {
ControlGetText, ControlName, ToolbarWindow%ToolbarWindowNumber%, ahk_class #32770
If ControlName = Mute for Windows Media Player
{
ControlSend, msctls_trackbar%msctls_trackbarNumber%, {Up}, ahk_class #32770 ; Use {Up 2} to change sound level faster
Break
} Else {
If ToolbarWindowNumber < 328
{
ToolbarWindowNumber := ToolbarWindowNumber + 2
msctls_trackbarNumber := msctls_trackbarNumber + 1
} Else {
If ToolbarWindowNumber = 328
{
ToolbarWindowNumber = 3210
msctls_trackbarNumber := msctls_trackbarNumber + 1
} Else {
If ToolbarWindowNumber < 3242
{
ToolbarWindowNumber := ToolbarWindowNumber + 2
msctls_trackbarNumber := msctls_trackbarNumber + 1
} Else {
MsgBox, 16, AutoHotkey, ERROR: Application's volume control was not found!`nThis could occur if the Volume Mixer has more than 20 opened applications
Break
}
}
}
}
}
}
Return

我试过了,它可以与 Windows Media Player 一起使用,但我无法在 Google Chrome 上使用它。

我在 IfWinExist, Windows Media Player 上更改了一些代码并将其更改为 IfWinExist, Google Chrome但没有调整Chrome的音量。

我正在运行 Windows 10 64 位

最佳答案

  • 全部替换 IfWinExist, Windows Media PlayerIfWinExist ahk_class Chrome_WidgetWin_1
  • 全部替换 If ControlName = Mute for Windows Media Playerif (ControlName ~= "Mute for.*- Google Chrome")

  • 您可以使用 Autohotkey Window Spy 实用程序来查找值。右键单击任务栏托盘通知区域中的任何 AHK 图标,然后选择“Window Spy”。

    或者使用真棒 nircmd实用程序:
    ^#Up::run nircmd changeappvolume focused +0.1
    ^#Down::run nircmd changeappvolume focused -0.1
    ^#Numpad0::run nircmd muteappvolume focused 2

    Ctrl+Win+Up = 提高事件应用的音量
    Ctrl+Win+Down = 降低事件应用程序的音量
    Ctrl+Win+Numpad 0 = 静音/取消静音事件应用程序

    替换 focused使用 app exe 名称来控制特定的应用程序,例如 chrome.exe , vlc.exe

    关于Autohotkey - 如何仅调整特定程序的音量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38433170/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com