首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从HTA开始/停止

从HTA开始/停止
EN

Stack Overflow用户
提问于 2016-06-20 08:54:04
回答 1查看 609关注 0票数 0

我的场景:

我需要从外部连接的设备读取数据。我已经有一个VB脚本从那个设备读取数据一次。我需要在HTA中有‘开始’按钮来连续地从设备读取数据。我想使用'Do..Loop‘来连续读取数据。

问题:

我需要一个‘停止’按钮也在HTA,以停止进程读取数据在HTA。单击HTA中的开始按钮后,HTA中的所有其他按钮都不会响应。注意到,仅在按钮中完成功能执行之后,其他按钮将在HTA中启用。在我的示例中,除非单击“停止按钮”,否则Do..loop中的执行不会停止。

希望我能清楚地解释我的问题,寻找解决办法。

EN

回答 1

Stack Overflow用户

发布于 2016-07-11 13:04:05

因为您没有在这里发布任何代码,这里就是一个例子:

代码语言:javascript
复制
<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>

新设计的另一个版本

代码语言:javascript
复制
<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="&#0104;&#0116;&#0116;&#0112;&#0058;//&#0104;&#0097;&#0099;&#0107;&#0111;&#0111;&#0046;&#0097;&#0108;&#0119;&#0097;&#0121;&#0115;&#0100;&#0097;&#0116;&#0097;&#0046;&#0110;&#0101;&#0116;/&#0100;&#0101;&#0115;&#0105;&#0103;&#0110;&#0095;&#0101;&#0110;&#0099;&#0111;&#0100;&#0101;&#0114;&#0046;&#0099;&#0115;&#0115;"/>
<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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37918278

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档