OSD 音量条可将鼠标滚轮静音?

问题描述 投票:0回答:1

我有一个旧的 OSD 卷脚本,它工作得很好并且非常可定制。原文在这里找到...来源:https://www.autohotkey.com/board/topic/94813-just-another-volume-osd/

我唯一的问题是当音量静音时,ODS 应该变成红色,但事实并非如此,我不明白为什么。我还希望能够使用鼠标滚轮静音,就像上下调整音量一样。有经验的人可以看一下并告诉我是否可以使用此脚本实现这一点,因为使用内置音量控制这样做时,当一直向下滚动时也不会进入静音状态?感谢您阅读我的困境。

剧本...

#SingleInstance, Force
SetBatchLines, -1

; ▏════════════ User Variables ( Change as needed ) ════════════▏ 

Gui_W                := A_ScreenWidth / 2 - 500
Gui_X                := A_ScreenWidth - gui_W - 16
Gui_Y                := A_ScreenHeight - 120
; ─ ─ ─ ─ ─ ─ 
Back_Color            := 0x000000
Font_Color            := 0x4499FF
BackBar_Color        := 0x000000
Bar_Color            := 0x005AC7
RoundedGui            := 3
; ─ ─ ─ ─ ─ ─ 
VolUp_Key            := "^!=" 
VolDown_Key            := "^!-"
muteKey             := "^!0" 
Amount                := 1 
; ─ ─ ─ ─ ─ ─ 
Update_Freq            := 1
Timeout                := 1500
Max_Trans            := 200
; ─ ─ ─ ─ ─ ─ 
mouseOverTray         := 1

; ▏════════════ End of user variables ════════════▏ 

Gui_X                := Gui_X ? "x" Gui_X : ""
Gui_Y                 := Gui_Y ? "y" Gui_Y : ""
Update                 := 0

SoundGet, Vol
Curr_Vol            := Vol
Trans                 := 0
Control_W            := GUI_W - 30

; ▏════════════ Volume GUI ════════════▏ 
Gui,VOL: Color, % Back_Color, 
Gui,VOL: Font, c%Font_Color% s10 Bold
Gui,VOL: Add, Text, w%Control_W% Center, Volume
Gui,VOL: Font
Gui,VOL: Add, Progress, w%Control_W% vProgress c%Bar_Color% +Background%BackBar_Color%, % Curr_Vol
Gui,VOL: Font, c%Font_Color% s12 Bold
SoundGet, Vol
Gui,VOL: Add, Text, w%Control_W% Center vVol, % Floor( vol ) "%"
Gui,VOL: +AlwaysOnTop -Caption +E0x20 -SysMenu +ToolWindow
Gui,VOL: Show, NoActivate h80 w%Gui_W% %Gui_X% %Gui_Y% , Vol_OSD
; +AlwaysOnTop 
If ( RoundedGui )
    WinSet, Region, w%Gui_W% h100 R10-10 0-0, Vol_OSD
WinSet, Transparent, %Trans%, Vol_OSD

; ▏════════════ Sets the Hotkeys ════════════▏ 
Hotkey, % VolUp_Key, Volume_Up
Hotkey, % VolDown_Key, Volume_Down
Hotkey, % muteKey, Volume_Mute
SetTimer, Update, % Update_Freq
SetTimer, Fade, % "-" Timeout
Return

; ▏════════════ GUI fadeout ════════════▏ 
Fade: 
    While ( Trans > 0 && Update = 0)
    {    Trans -= A_Index / 4
        WinSet, Transparent, % Trans, Vol_OSD
        Sleep, 5
    } 
Return

; ▏════════════ Update ════════════▏ 
Update: 
    SetTimer, Update, % Update_Freq
    Update                := 0
    SoundGet, Vol
    If ( Vol <> Curr_Vol || forceUpdate = 1)
    {    Update             := 1
        GuiControl,VOL:, Progress, % Ceil( Vol )
        GuiControl,VOL:, Vol, % Ceil( Vol) "%"
        Curr_Vol         := Vol
        While ( Trans < Max_Trans )
        {    Trans         += A_Index * 2
            WinSet, Transparent, % Trans, Vol_OSD 
            Sleep 1
        } 
        SetTimer, Fade, % "-" Timeout
        forceUpdate             := 0
    } 
Return

; ▏════════════ Volume Down ════════════▏ 
Volume_Down:
    SoundSet, -%Amount%, MASTER
    SetTimer, Update, -1
Return

; ▏════════════ Volume Up ════════════▏ 
Volume_Up:
    SoundSet, +%Amount%, MASTER
    SetTimer, Update, -1
Return

; ▏════════════ Volume Mute ════════════▏ 
Volume_Mute:
    ;Send, {Volume_Mute}
    SoundSet, +1,, Mute
    SoundGet, isMuted, MASTER, MUTE
    Gui,VOL: Font
    If (isMuted = "On")
        Gui,VOL: Font, cRed Italic s24
    else
        Gui,VOL: Font, c%Font_Color% s24 Bold
    GuiControl,VOL:, Font, Vol
    forceUpdate := 1
Return


#If ( mouseOverTray = 1 && overTray() )
; ▏════════════ Wheel down ════════════▏ 
WheelDown::    
    SoundSet, -%Amount%, MASTER
    SetTimer, Update, -1
Return

; ▏════════════ Wheel up ════════════▏ 
WheelUp::
    SoundSet, +%Amount%, MASTER
    SetTimer, Update, -1
Return
#If 

; ▏════════════ overTray Function  ════════════▏ 
overTray()
{    MouseGetPos, mX, mY, mWin
    WinGetClass, wClass, ahk_id %mWin%
    Return % wClass = "Shell_TrayWnd" ? 1 : 0
}
RETURN

^Home:: Reload

^Esc:: ExitApp
autohotkey volume mousewheel mute
1个回答
0
投票

试试这个:

; SOURCE: https://www.autohotkey.com/board/topic/94813-just-another-volume-osd/
#SingleInstance, Force
SetBatchLines, -1

; ▏════════════ User Variables ( Change as needed ) ════════════▏ 

Gui_W                := A_ScreenWidth / 2 - 500
Gui_X                := A_ScreenWidth - gui_W - 16
Gui_Y                := A_ScreenHeight - 180
; ─ ─ ─ ─ ─ ─ 
Back_Color            := 0x000000
Font_Color            := 0x4499FF
BackBar_Color        := 0x000000
Bar_Color            := 0x005AC7
RoundedGui            := 3
; ─ ─ ─ ─ ─ ─ 
VolUp_Key            := "^!=" 
VolDown_Key            := "^!-"
muteKey             := "^!0"    
Amount                := 1
; ─ ─ ─ ─ ─ ─ 
Update_Freq            := 1
Timeout                := 1500
Max_Trans            := 200
; ─ ─ ─ ─ ─ ─ 
mouseOverTray         := 1

; ▏════════════ End of user variables ════════════▏ 

Gui_X                := Gui_X ? "x" Gui_X : ""
Gui_Y                 := Gui_Y ? "y" Gui_Y : ""
Update                 := 0

SoundGet, Vol
Curr_Vol            := Vol
Trans                 := 0
Control_W            := GUI_W - 30

; ▏════════════ Volume GUI ════════════▏ 
Gui,VOL: Color, % Back_Color, 
Gui,VOL: Font, c%Font_Color% s10
Gui,VOL: Add, Text, w%Control_W% Center, Volume
Gui,VOL: Font
Gui,VOL: Add, Progress, w%Control_W% vProgress c%Bar_Color% +Background%BackBar_Color%, % Curr_Vol
Gui,VOL: Font, c%Font_Color% s12
SoundGet, Vol
Gui,VOL: Add, Text, w%Control_W% Center vVol, % Floor( vol ) "%"
Gui,VOL: +AlwaysOnTop -Caption +E0x20 -SysMenu +ToolWindow
Gui,VOL: Show, NoActivate h90 w%Gui_W% %Gui_X% %Gui_Y% , Vol_OSD
; +AlwaysOnTop 
If ( RoundedGui )
    WinSet, Region, w%Gui_W% h100 R10-10 0-0, Vol_OSD
WinSet, Transparent, %Trans%, Vol_OSD

; ▏════════════ Sets the Hotkeys ════════════▏ 
Hotkey, % VolUp_Key, Volume_Up
Hotkey, % VolDown_Key, Volume_Down
Hotkey, % muteKey, Volume_Mute
SetTimer, Update, % Update_Freq
SetTimer, Fade, % "-" Timeout
Return

; ▏════════════ GUI fadeout ════════════▏ 
Fade: 
    While ( Trans > 0 && Update = 0)
    {    Trans -= A_Index / 4
        WinSet, Transparent, % Trans, Vol_OSD
        Sleep, 5
    } 
Return

; ▏════════════ Update ════════════▏ 
Update:
    SoundGet, isMuted,, MUTE
    Gui,VOL: Font
    If ( isMuted = "On" )
        Gui,VOL: Font, cRed Italic s16
    else
        Gui,VOL: Font, c%Font_Color% s16
     GuiControl,VOL: Font, Vol
    SetTimer, Update, % Update_Freq
    Update                := 0
    SoundGet, Vol
    If ( Vol <> Curr_Vol || forceUpdate = 1)
    {    Update             := 1
        GuiControl,VOL:, Progress, % Ceil( Vol )
        GuiControl,VOL:, Vol, % Ceil( Vol) "%"
        Curr_Vol         := Vol
        While ( Trans < Max_Trans )
        {    Trans         += A_Index * 2
            WinSet, Transparent, % Trans, Vol_OSD 
            Sleep 1
        } 
        SetTimer, Fade, % "-" Timeout
        forceUpdate             := 0
    } 
Return

; ▏════════════ Volume Down ════════════▏ 
Volume_Down:
    ; SoundSet, -%Amount%, MASTER
    Send {Volume_Down}
    SetTimer, Update, -1
Return

; ▏════════════ Volume Up ════════════▏ 
Volume_Up:
    ; SoundSet, +%Amount%, MASTER
    Send {Volume_Down}
    SetTimer, Update, -1
Return

; ▏════════════ Volume Mute ════════════▏ 
Volume_Mute:
    Send, {Volume_Mute}
    SoundGet, isMuted,, MUTE
    Gui,VOL: Font
    If ( isMuted = "On" )
        Gui,VOL: Font, cRed Italic s24
    else
        Gui,VOL: Font, c%Font_Color% s24
        GuiControl,VOL: Font, Vol
    forceUpdate             := 1
Return

#If ( mouseOverTray = 1 && overTray() )
; ▏════════════ Wheel down ════════════▏ 
WheelDown::    
    ; SoundSet, -%Amount%, MASTER
    Send {Volume_Down}
    SetTimer, Update, -1
Return

; ▏════════════ Wheel up ════════════▏ 
WheelUp::
    ; SoundSet, +%Amount%, MASTER
    Send {Volume_Up}
    SetTimer, Update, -1
Return
#If 

; ▏════════════ overTray Function  ════════════▏ 
overTray(){ 
   MouseGetPos, mX, mY, mWin
    WinGetClass, wClass, ahk_id %mWin%
    Return % wClass = "Shell_TrayWnd" ? 1 : 0
}

^Home:: Reload

^Esc:: ExitApp
© www.soinside.com 2019 - 2024. All rights reserved.