2017-08-16 7 views
2

私は私の窓の上に7 PCをシステムサウンドをミュートするためのソリューションを探しています、と私は多くの場所には、以下のVBスクリプトをお勧めしますが見つかりました:vbスクリプトがWindows 7 PCでサウンドをミュートするのがなぜ機能しないのですか?

Set WshShell = CreateObject("WScript.Shell") 
WshShell.SendKeys(chr(&hAD)) 

または

Set WshShell = CreateObject("WScript.Shell") 
WshShell.SendKeys(chr(173)) 

だから私は上記を保存"sound.vbs"というファイルへの行をダブルクリックして実行しますが、サウンドはまだオンになっています、なぜですか?それを行う正しい方法は何ですか?

答えて

1

このスクリプトとして実行する必要があります

set oShell = CreateObject("wscript.shell") 
oShell.SendKeys(" " & chr(173)) 'Allows you to toggle(mute/unmute) 

私は古いHTAファイルを持っており、それは、Windows 7上で私の仕事:Sound.hta

<html> 
<head> 
<HTA:APPLICATION 
APPLICATIONNAME="Volume + - ON/OFF" 
BORDER="THIN" 
BORDERSTYLE="NORMAL" 
ICON="SndVol.exe" 
INNERBORDER="NO" 
MAXIMIZEBUTTON="NO" 
MINIMIZEBUTTON="NO" 
SCROLL="NO" 
SELECTION="NO" 
SINGLEINSTANCE="YES"/> 
<title>Volume + - ON/OFF </title> 
<script language="vbscript"> 
'************************************************************************************ 
Sub window_onload() 
    CenterWindow 250,150 
End Sub 
'************************************************************************************ 
Sub Sleep(MSecs)' Fonction pour faire une pause car wscript.sleep ne marche pas dans un HTA 
    Set fso = CreateObject("Scripting.FileSystemObject") 
    Dim tempFolder : Set tempFolder = fso.GetSpecialFolder(2) 
    Dim tempName : tempName = "Sleeper.vbs" 
    If Not Fso.FileExists(tempFolder&"\"&tempName) Then 
     Set objOutputFile = fso.CreateTextFile(tempFolder&"\"&tempName, True) 
     objOutputFile.Write "wscript.sleep WScript.Arguments(0)" 
     objOutputFile.Close 
    End If 
    CreateObject("WScript.Shell").Run tempFolder&"\"&tempName &" "& MSecs,1,True 
End Sub 
'************************************************************************************ 
Sub Volume(Param) 
    set oShell = CreateObject("WScript.Shell") 
    Select Case Param 
    Case "MAX" 
     oShell.run "%SystemRoot%\System32\SndVol.exe" 'Runs The Master Volume App. 
     Sleep 2000 'Waits For The Program To Open 
     oShell.SendKeys("{HOME}")' volume maximum 100% 
     Sleep 100 
     oShell.SendKeys"%{F4}" ' ALT + F4 
    Case "MIN" 
     oShell.run "%SystemRoot%\System32\SndVol.exe" 'Runs The Master Volume App. 
     Sleep 2000 'Waits For The Program To Open 
     oShell.SendKeys("{END}") 'volume minimum 0% 
     Sleep 1000 
     oShell.SendKeys"%{F4}" ' ALT + F4 
    Case "UP" 
     oShell.run "%SystemRoot%\System32\SndVol.exe" 'Runs The Master Volume App. 
     Sleep 2000 'Waits For The Program To Open 
     oShell.SendKeys("{PGUP}") 'volume +20% 
     Sleep 1000 
     oShell.SendKeys"%{F4}" ' ALT + F4 
    Case "DOWN" 
     oShell.run "%SystemRoot%\System32\SndVol.exe" 'Runs The Master Volume App. 
     Sleep 2000 'Waits For The Program To Open 
     oShell.SendKeys("{PGDN}") 'Turns Up The Volume 20, If It Is Muted Then It Will Unmute It 
     Sleep 1000 
     oShell.SendKeys"%{F4}" ' ALT + F4 
    Case "MUTE" 
     oShell.run "%SystemRoot%\System32\SndVol.exe" 'Runs The Master Volume App. 
     Sleep 1000 'Waits For The Program To Open 
     oShell.SendKeys(" " & chr(173)) 'permet de couper/remettre le son (bascule) 
     Sleep 1000 
     oShell.SendKeys"%{F4}" ' ALT + F4 
    End select 
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 
'************************************************************************************ 
</script> 
</head> 
<body> 
<center> 
<BUTTON style="background: Red; color: white;" onClick="Call Volume('MAX')" style="WIDTH: 85px; HEIGHT: 30px">Volume MAX</BUTTON>&nbsp;&nbsp; 
<BUTTON style="background: Blue; color: white;" onClick="Call Volume('MIN')" style="WIDTH: 85px; HEIGHT: 30px">Volume MIN</BUTTON>&nbsp;&nbsp; 
<BUTTON style="background: Green; color: white;" onClick="Call Volume('UP')" style="WIDTH: 85px; HEIGHT: 30px">Volume +20%</BUTTON>&nbsp;&nbsp; 
<BUTTON style="background: Orange; color: white;" onClick="Call Volume('DOWN')" style="WIDTH: 85px; HEIGHT: 30px">Volume -20%</BUTTON>&nbsp;&nbsp; 
<BUTTON style="background: DarkOrange; color: white;" onClick="Call Volume('MUTE')" style="WIDTH: 85px; HEIGHT: 30px">ON/OFF</BUTTON>&nbsp;&nbsp; 
</center> 
</body> 
</html> 
関連する問題