求一个能在全屏画面下显示麦克风状态的软件

我一直在 哔哩哔哩 做直播,想要可以在全屏画面下看到麦克风状态图标,我必须按下 FN 加 F4 查看麦克风的状态。但是我想要在全屏画面下能看到麦克风的状态是不是被静音了。

我觉得得先问一个问题,就是你用的是OBS还是直播姬

OBS 作为推流软件,直播姬做转发来自 OBS 的视频流至服务器

F4 作为麦克风的快捷键的话,按搜索结果来看应该是 戴尔/联想 笔记本的特性?并非 Windows 原生功能。

我感觉先搞清楚这个静音原理是啥再讨论比较好。如果是驱动层面的话可能比较麻烦;如果单纯是把系统麦克风静音的话,理论上找 AI 写个小脚本就可以,不过如果是游戏直播的话有被误判成挂的风险。

装个autohotkey

然后用下面的码一个ahk文件就行,如果需要gui可以问问DeepSeek :grinning_face_with_smiling_eyes:



; 获取麦克风的静音状态
muteState := SoundGetMute("", "Microphone")

; 判断状态:1 为静音,0 为非静音
if (muteState = 1)
    MsgBox "麦克风当前处于静音状态"
else
    MsgBox "麦克风当前未静音"

你提供的代码用不了了

版本不对吗?

; AHK v1 版本
SoundGet, microphone_mute, Microphone, Mute
if (microphone_mute = "On")  ; 注意 v1 返回的是 "On"/"Off" 字符串
    MsgBox, 麦克风当前处于静音状态
else
    MsgBox, 麦克风当前未静音

需要轮询可以试试下面的

#Persistent
SetTimer, CheckMic, 500

lastState := ""

CheckMic:
    SoundGet, mute, Microphone, , Mute
    if (mute = "On")
        state := "静音"
    else if (mute = "Off")
        state := "未静音"
    else
        state := "无法读取"

    if (state != lastState) {
        lastState := state
        TrayTip, 麦克风状态, 当前:%state%
    }
return

我的是 2.0 版本

也许你可能能用这个来做个插件实现一下?
不知道能不能满足你全屏需求哈… :sweat_smile:
因为windows上全屏游戏是无法显示子窗口的 :smiling_face_with_tear:

我的锅,做了下研究,可以再试试如下:
首先,用这个ahk脚本侦测麦克风的性质(来自AHK官方)

scGui := Gui(, "Sound Components")
scLV := scGui.Add('ListView', "w600 h400"
    , ["Component", "#", "Device", "Volume", "Mute"])

devMap := Map()

loop
{
    ; For each loop iteration, try to get the corresponding device.
    try
        devName := SoundGetName(, dev := A_Index)
    catch  ; No more devices.
        break
    
    ; Qualify names with ":index" where needed.
    devName := Qualify(devName, devMap, dev)
    
    ; Retrieve master volume and mute setting, if possible.
    vol := mute := ""
    try vol := Round(SoundGetVolume( , dev), 2)
    try mute := SoundGetMute( , dev)
    
    ; Display the master settings only if at least one was retrieved.
    if vol != "" || mute != ""
        scLV.Add("", "", dev, devName, vol, mute)
    
    ; For each component, first query its name.
    cmpMap := Map()
    
    loop
    {
        try
            cmpName := SoundGetName(cmp := A_Index, dev)
        catch
            break
        ; Retrieve this component's volume and mute setting, if possible.
        vol := mute := ""
        try vol := Round(SoundGetVolume(cmp, dev), 2)
        try mute := SoundGetMute(cmp, dev)
        ; Display this component even if it does not support volume or mute,
        ; since it likely supports other controls via SoundGetInterface().
        scLV.Add("", Qualify(cmpName, cmpMap, A_Index), dev, devName, vol, mute)
    }
}

loop 5
    scLV.ModifyCol(A_Index, 'AutoHdr Logical')
scGui.Show()

; Qualifies full names with ":index" when needed.
Qualify(name, names, overallIndex)
{
    if name = ''
        return overallIndex
    key := StrLower(name)
    index := names.Has(key) ? ++names[key] : (names[key] := 1)
    return (index > 1 || InStr(name, ':') || IsInteger(name)) ? name ':' index : name
}

比如我这里是 component “1” device “8”

然后,用下面的GUI脚本就可以了

; 创建 GUI:置顶、工具窗口属性(不在任务栏显示)
myGui := Gui("+AlwaysOnTop +ToolWindow +E0x20") ; E0x20 使窗口点击穿透(可选)
myGui.BackColor := "202020"
myGui.SetFont("s12 cWhite", "Segoe UI")

; 添加一个文本控件,初始显示未知
statusText := myGui.AddText("w200 h30 Center", "检测中...")

; 在屏幕右下角附近显示,不激活窗口
myGui.Show("x" A_ScreenWidth-420 " y" A_ScreenHeight-200 " NoActivate")

lastState := ""
SetTimer CheckMic, 500

CheckMic() {
    global lastState, statusText
    try {
        muteState := SoundGetMute(1, 8) ; 注意这里填写你的"Component"和"Device#"
        state := (muteState = 1) ? "静音" : "未静音"
        color := (muteState = 1) ? "cRed" : "cLime" ; 静音红,未静音绿
    } catch {
        state := "无法读取"
        color := "cGray"
    }
    if (state != lastState) {
        lastState := state
        statusText.Text := "麦克风: " state
        statusText.SetFont(color) ; 切换文字颜色
    }
}

然后你应该能看到:

至于更通用的,可能需要声卡检测,声纹检测什么的,我觉得应该不必要。。。

我觉得可以买一个带指示灯的麦克风

算了,我还是自己用 AI 开发吧……

开发出来了,右下角是麦克风状态:

可以了,代码已上线 GitHub,快去使用吧!