我的方案:
我需要从外部连接的设备读取数据。我已经有一个VB脚本来从该设备读取数据一次。我需要在HTA中使用“开始”按钮从设备连续读取数据。我想用'Do..Loop'连续读取数据。
问题:
我还需要在HTA中设置一个“停止”按钮来停止在HTA中读取数据的过程。 点击HTA中的“开始”按钮后,HTA中的所有其他按钮都没有响应。观察到完成执行功能仅在按钮后,HTA中启用了其他按钮。在我的情况下,除非我单击“停止按钮”,否则执行不会在Do..loop中暂停。
希望我能清楚地解释我的问题,寻找解决方案。
答案 0 :(得分:0)
由于您未在此处发布任何代码,因此是一个示例:
<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>