windows脚本控制声音大小

voice.vbs

Set ws = CreateObject("WScript.Shell")
Set oArgs = WScript.Arguments
If oArgs(0) = 0 Then
	ws.SendKeys Chr(&H88AD) '静音非静音切bai换 
ElseIf oArgs(0) = 1 Then
	ws.SendKeys Chr(&H88AE) '减小音量
ElseIf oArgs(0) = 2 Then
	ws.SendKeys Chr(&H88AF) '增大音量88AF
ElseIf oArgs(0) = 3 Then'音量最大
	For i = 1 To 99
		ws.SendKeys Chr(&H88AF) 
	Next
ElseIf oArgs(0) = 4 Then'音量最小
	For i = 1 To 100
		ws.SendKeys Chr(&H88AE) 
	Next
ElseIf oArgs(0) = 5 Then'音量指定
	For i = 1 To 100
		ws.SendKeys Chr(&H88AE) 
	Next
	For i = 1 To oArgs(1)/2
		ws.SendKeys Chr(&H88AF) 
	Next
End If

bat调用

@echo off

rem 传参0表示静音&非静音的切换,1表示减少音量,2是增加,3变成最大,4变成最小,5再接数字表示指定音量(0-100)
C:\Users\20531\Desktop\bat\voice.vbs 5 50
echo 搞定!

如需只要一个bat实现,则需要先使用bat将vbs的内容写入,再调用。

你可能感兴趣的:(计算机基础,windows,windows脚本控制声音)