我的场景:
我需要从外部连接的设备读取数据。我已经有一个VB脚本从那个设备读取数据一次。我需要在HTA中有‘开始’按钮来连续地从设备读取数据。我想使用'Do..Loop‘来连续读取数据。
问题:
我需要一个‘停止’按钮也在HTA,以停止进程读取数据在HTA。单击HTA中的开始按钮后,HTA中的所有其他按钮都不会响应。注意到,仅在按钮中完成功能执行之后,其他按钮将在HTA中启用。在我的示例中,除非单击“停止按钮”,否则Do..loop中的执行不会停止。
希望我能清楚地解释我的问题,寻找解决办法。
发布于 2016-07-11 13:04:05
因为您没有在这里发布任何代码,这里就是一个例子:
<html>
<head>
<title>Start and Stop music Example</title>
<SCRIPT Language="VBScript">
Sub PlayMusic(URL)
Call DisableButton1()
Dim STRHTML
STRHTML = "<br>"
STRHTML = STRHTML & "<bgsound src="& url &" loop=""infinite"">"
MyMusic.InnerHTML = STRHTML
End Sub
'******************************************
Sub DisableButton1()
button1.disabled = True
button2.disabled = False
End Sub
'******************************************
Sub DisableButton2()
button2.disabled = True
button1.disabled = False
End Sub
'******************************************
Sub StopMusic()
Call DisableButton2()
MyMusic.InnerHTML = ""
End Sub
'******************************************
</SCRIPT>
</head>
<body>
<input type="button" name="button1" value="Start the Music" onclick='PlayMusic("http://hackoo.alwaysdata.net/Matrix.mp3")'>
<input type="button" name="button2" value="Stop the Music" onclick="StopMusic()">
<span id ="MyMusic"></span>
</body>
</html>新设计的另一个版本
<html>
<HTA:APPLICATION
MAXIMIZEBUTTON="no"
ICON="Winver.exe"
SCROLL="No"
SCROLLFLAT="yes"
SINGLEINSTANCE="yes"
CONTEXTMENU="no"
SELECTION="no"/>
<head>
<link rel="stylesheet" media="screen" type="text/css" title="design_encoder" href="http://hackoo.alwaysdata.net/design_encoder.css"/>
<title>Start and stop the music by Hackoo 2016</title>
<SCRIPT Language="VBScript">
'*******************************************
Sub Window_OnLoad
CenterWindow 400,220
End Sub
'*******************************************
Sub CenterWindow(x,y)
window.resizeTo x, y
iLeft = window.screen.availWidth/2 - x/2
itop = window.screen.availHeight/2 - y/2
window.moveTo ileft, itop
End Sub
'*******************************************
Sub PlayMusic(URL)
Call DisableButton1()
Dim STRHTML
STRHTML = "<br>"
STRHTML = STRHTML & "<bgsound src="& url &" loop=""infinite"">"
MyMusic.InnerHTML = STRHTML
End Sub
'******************************************
Sub DisableButton1()
button1.disabled = True
button2.disabled = False
End Sub
'******************************************
Sub DisableButton2()
button2.disabled = True
button1.disabled = False
End Sub
'******************************************
Sub StopMusic()
Call DisableButton2()
MyMusic.InnerHTML = ""
End Sub
'******************************************
</SCRIPT>
</head>
<body>
<br><br><hr>
<center><input type="button" name="button1" value="Start the Music" onclick='PlayMusic("http://hackoo.alwaysdata.net/Matrix.mp3")'>
<input type="button" name="button2" value="Stop the Music" onclick="StopMusic()">
<hr>
<span id ="MyMusic"></span>
<center>
</body>
</html>https://stackoverflow.com/questions/37918278
复制相似问题