little script for speaker voice on office laptop

My computer's headphone connector is broken.
When play music the speaker has no sound, even no headphone is inserted, and speaker is the default playback device.

So, write this VBS script to make focus and change volume of headphone, then speaker could make sounds...

My computer's headphone connector is broken.
When play music the speaker has no sound, even no headphone is inserted, and speaker is the default playback device.
So, write this VBS script to make focus and change volume of headphone, then speaker could make sounds...
set oShell = CreateObject("WScript.Shell") 
oShell.run "%SystemRoot%\System32\SndVol.exe" 
WScript.Sleep 100 
oShell.SendKeys"+{TAB}" ' Tab to the mute and press space
WScript.Sleep 100 
oShell.SendKeys"+{TAB}" ' Tab to the mute and press space
WScript.Sleep 100 
oShell.SendKeys"{DOWN}" ' Tab to the mute and press space
WScript.Sleep 100 
oShell.SendKeys"{DOWN}" ' Tab to the mute and press space
WScript.Sleep 100 	
oShell.SendKeys"{ENTER}" ' Tab to the mute and press space
WScript.Sleep 100 
oShell.SendKeys"{TAB}" ' Tab to the mute and press space			
WScript.Sleep 100 
oShell.SendKeys"{TAB}" ' Tab to the mute and press space
Dim counter					
counter = 20
While counter > 0
    oShell.AppActivate "Volume Mixer"
	oShell.SendKeys"{TAB}" ' Tab to the mute and press space
    WScript.Sleep 200 
    oShell.SendKeys"{TAB}" ' Tab to the mute and press space
    oShell.SendKeys"{DOWN}" ' Tab to the mute and press space
    WScript.Sleep 500
	oShell.SendKeys"{UP}" ' Tab to the mute and press space
	WScript.Sleep 500
    counter = counter - 1
Wend

oShell.AppActivate "Volume Mixer"
oShell.SendKeys"%{F4}"  ' ALT F4 to exit the app.
set oShell = nothing

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章