通过快捷方式切换主显示器和音频设备

通过快捷方式切换主显示器和音频设备

有没有办法在 Windows 10 中快速切换主显示器和音频设备?我经常在 PC 显示器和扬声器与连接的电视(显示器和内置扬声器)之间切换。在 Windows 中一直手动切换这些很麻烦。

是否有一些快捷方式或基于配置文件的解决方案,希望无需安装其他软件?是否可以通过批处理文件或其他方式实现?

答案1

參閱如何在 Windows 10 中更改默认音频设备

对此 Windows 10 Rundll32 命令 – 完整列表


将此行复制并粘贴到记事本或 Notepad++ 上,然后将其保存为SwitchSound.vbs桌面

CreateObject("wscript.shell").Run "rundll32.exe shell32.dll,Control_RunDLL mmsys.cpl,,0"

或者使用这样的批处理文件:SwitchSound.bat

@echo off
Start rundll32.exe shell32.dll,Control_RunDLL mmsys.cpl,,0

编辑:2020/09/09 @ 02:50

我已将完整的列表命令捆绑Rundll32.exe Shell32.dll到 HTA 文件中

在此处输入图片描述


您的命令在 40 中如下所示:

在此处输入图片描述


<html>
<HTA:APPLICATION 
 APPLICATIONNAME="Rundll32.exe Shell32.dll Commands List by Hackoo 2020" 
 BORDER="THIN"
 BORDERSTYLE="NORMAL"
 ICON="DxDiag.exe"
 INNERBORDER="NO"
 MAXIMIZEBUTTON="NO"
 MINIMIZEBUTTON="YES"
 SCROLL="NO"
 SELECTION="NO"
 SINGLEINSTANCE="YES"/>
 <META HTTP-EQUIV="MSThemeCompatible" CONTENT="YES">
<head>
<title>Rundll32.exe Shell32.dll Commands List by Hackoo 2020</title>
<style>
body {
    background-color:lightblue;
    background-image: url('https://animaloilmaker.com/images/gif-green-matrix.gif');
}
</style>
</head>
<body>
<center>
<hr><br>
<select name="Command"></select>
<br><br><hr><br>
<Input Type="button" Value="Execute Rundll32.exe Shell32.dll Command" OnClick="Execute(Command.value)">
</center>
</body>
</html>
<script type="text/vbscript">
Option Explicit
Dim URL,Save2File
URL = "https://pastebin.com/raw/F4AC0YDS"
Save2File = "Rundll32_Commands.csv"
'------------------------------------------------------------------------------------------------------
Sub Window_OnLoad()
    CenterWindow 570,230
    Call Download(URL,Save2File)
    Call LoadFile(Save2File)
End Sub
'------------------------------------------------------------------------------------------------------
Sub CenterWindow(x,y)
    Dim iLeft,itop
    window.resizeTo x,y
    iLeft = window.screen.availWidth/2 - x/2
    iTop = window.screen.availHeight/2 - y/2
    window.moveTo iLeft, iTop
 End Sub
'------------------------------------------------------------------------------------------------------
Sub LoadFile(strFile)
Dim strContents,Count,Tab,i,objOption
    Call ClearListbox()
    strContents = ReadFile(strFile)
    Count = 0
    Tab = split(strContents,vbcrlf)
    For i = lbound(Tab) to ubound(Tab) Step 1
        Count = Count + 1
        Set objOption = Document.createElement("OPTION")
        objOption.Text =  Count & "-" & Trim(Split(Tab(i),";")(0)) 
        If i > UBound(tab) Then Exit For
        objOption.Value = Trim(Split(Tab(i),";")(1))
        Command.Add(objOption)      
    Next    
End Sub
'------------------------------------------------------------------------------------------------------
Sub ClearListbox()
Dim objOption
    For Each objOption in Command.Options
        objOption.RemoveNode
    Next 
End Sub
'------------------------------------------------------------------------------------------------------
Sub Execute(Command)
    Dim Title : Title = "Rundll32.exe Shell32.dll Commands List by Hackoo 2020"
    Dim Question
    Question = MsgBox("Did you want to execute this command ?" & vbcrlf & vbcrlf &_
    Command,vbQuestion+VbYesNo,Title)
    If Question = vbYes Then
        CreateObject("wscript.Shell").Run Command,1,True
    Else
        Exit Sub
    End If
End Sub
'------------------------------------------------------------------------------------------------------
Sub Download(URL,Save2File)
    Dim File,Line,BS,ws
    On Error Resume Next
    Set File = CreateObject("WinHttp.WinHttpRequest.5.1")
    File.Open "GET",URL, False
    File.Send()
    If err.number <> 0 then
        Line  = Line &  vbcrlf & "Error Getting File"
        Line  = Line &  vbcrlf & "Error " & err.number & "(0x" & hex(err.number) & ") " &  vbcrlf &_
        err.description
        Line  = Line &  vbcrlf & "Source " & err.source
        MsgBox Line,vbCritical,"Error getting file"
        Err.clear
        Self.close
    End If
    If File.Status = 200 Then ' File exists and it is ready to be downloaded
        Set BS = CreateObject("ADODB.Stream")
        Set ws = CreateObject("wscript.Shell")
        BS.type = 1
        BS.open
        BS.Write File.ResponseBody
        BS.SaveToFile Save2File, 2
    ElseIf File.Status = 404 Then
        MsgBox "File Not found : " & File.Status,vbCritical,"Error File Not Found"
        Self.close
    Else
        MsgBox "Unknown Error : " & File.Status,vbCritical,"Error getting file"
        Self.close
    End If
End Sub
'------------------------------------------------------------------------------------------------------
Function ReadFile(InPutFile)
    Dim objFSO,oTS,sText
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set oTS = objFSO.OpenTextFile(InPutFile)
    sText = oTS.ReadAll
    oTS.close
    set oTS = nothing
    Set objFSO = nothing
    ReadFile = sText
End Function 
'------------------------------------------------------------------------------------------------------
</script>

相关内容