How to control Windows system volume using JScript or VBScript?

前端 未结 7 610
说谎
说谎 2020-12-03 06:10

I want to control the volume of my Windows system from a JScript or VBScript script. Any ideas?

Also, can I unmute the system volume if it is muted?

相关标签:
7条回答
  • 2020-12-03 06:50

    On Windows 7 I could do this by controlling the keystrokes using WScript.

    set oShell = CreateObject("WScript.Shell") 
    oShell.run"%SystemRoot%\System32\SndVol.exe" 
    WScript.Sleep 1500 
    oShell.SendKeys"{TAB} " ' Tab to the mute and press space
    oShell.SendKeys"%{F4}"  ' ALT F4 to exit the app.
    

    I saved it in to a file called Mute-Sound.vbs and created a shortcut on the desktop to assign a shortcut key. CTRL+ALT+F12. For some reason the keyboard shortcuts only work if they are on the desktop so I am not sure how reliable keyboard shortcuts are!

    0 讨论(0)
提交回复
热议问题