完成后停止Vbscript

时间:2017-03-18 15:50:53

标签: vbscript

当我注意到一个问题时,我正在制作一个名为cube的游戏。当我注意到大量的vbsscript运行时,我看了任务管理器Fr任何额外程序。我试着四处寻找,但没有脚本适合我。继承我的代码(播放A Sound)

Set Sound = CreateObject("WMPlayer.OCX.7")
Sound.URL = "Sounds\Hurt.mp3"
Sound.Controls.play
do while Sound.currentmedia.duration = 0
wscript.sleep 100
loop
wscript.sleep (int(Sound.currentmedia.duration)+1)*1000
WScript.Quit 1

它仍然不想停止。请帮助。

1 个答案:

答案 0 :(得分:1)

尝试以下示例

With CreateObject("WMPlayer.OCX.7")
    .URL = "C:\Users\DELL\Desktop\tmp\hit.wav"
    .controls.play
    Do
        WScript.Sleep 100
    Loop Until .playState = 1 Or .playState = 10
    ' .PlayState https://msdn.microsoft.com/en-us/library/windows/desktop/dd564085(v=vs.85).aspx
    ' "Stopped" (completed) or "Ready" (file not found)
End With