Sib*_*Lin 9 javascript windows vbscript volume mute
我想从JScript或VBScript脚本控制我的Windows系统的卷.有任何想法吗?
此外,如果系统音量静音,我可以取消静音吗?
要使系统音量静音或取消静音,您可以使用以下WshShell.SendKeys方法模拟静音键按下:
var oShell = new ActiveXObject("WScript.Shell");
oShell.SendKeys(Chr(&HAD));
至于从脚本更改音量级别,有一个涉及一些Windows自动化的解决方案,例如启动System Volume applet并模拟其中的相应键盘快捷键,但我认为它不可靠.因此,我建议您使用一些能够更改音量级别的外部实用程序,并从脚本中调用它.例如,您可以使用免费的NirCmd工具:
var oShell = new ActiveXObject("WScript.Shell");
// Increase the system volume by 20000 units (out of 65535)
oShell.Run("nircmd.exe changesysvolume 20000");
// Decrease the system volume by 5000 units
oShell.Run("nircmd.exe changesysvolume -5000");
NirCmd还可以将系统音量静音或取消静音:
var oShell = new ActiveXObject("WScript.Shell");
oShell.Run("nircmd.exe mutesysvolume 0");  // unmute
oShell.Run("nircmd.exe mutesysvolume 1");  // mute
oShell.Run("nircmd.exe mutesysvolume 2");  // switch between mute and unmute
小智 8
我可以看到在Windows上操作系统卷级别而无需安装其他软件的最佳方法是使用以下方法之一使用VBScript:
切换静音:(在之前的回答中已经提到)
Set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys(chr(&hAD))
提高音量:
Set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys(chr(&hAF))
降低音量:
Set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys(chr(&hAE))
这适用于大多数现代Windows机器.我已经在Windows 7和8.1上测试了它,即使在LC中使用"do as"运行它也能正常工作,因此可以将这些脚本嵌入到可执行文件中并运行它们而无需将它们另存为单个文件.
| 归档时间: | 
 | 
| 查看次数: | 38390 次 | 
| 最近记录: |