|
本帖最后由 kangatang 于 2012-5-21 12:39 编辑
因工作需要,想做一个UI,能提供些输入和选择的功能。我发现hta可以满足我的简单需求。修改后跟大家分享。
HTA是HTML Application的缩写(HTML应用程序),是软件开发的新概念,直接将HTML保存成HTA的格式,就是一个独立的应用软件,双击就能运行,与VB、C++等程序语言所设计的软件没什么差别。原来网页中的工具栏、地址栏以及菜单栏在这个窗口里都没有被显示出来,还可以使用html中的绝大多数标签、脚本等,这就给予你对界面设计更多的控制权。(天哪,当我看到这句话的时候,心情是多么的激动,这不是专为vbs脚本设计的gui界面吗?)
与普通HTML网页相比,它多了HTA:APPLICATION标签,其实就是这个标签提供了一系列面向应用程序的功能,这个特殊的标签,允许你控制这个应用程序的用户界面(UI)。<HTA:APPLICATION>标签位于<HEAD>标签里,它允许你控制诸如是否在所含的窗口里显示一个标题栏,或者显示最大最小化按钮。<HTA:APPLICATION>标签还让你能够访问客户的机器而不用担心安全的限制。
演示.rar
(867 Bytes, 下载次数: 926)
附件为hta文件,可以用notepad查看代码,具体如下:
////////////////////
更新:另有一个比较复杂点的范例共参考
http://club.excelhome.net/thread-869263-1-1.html
///////////////////
<script language=vbscript>
function window_onload
x=300
y=600
window.resizeTo x,y
x=(screen.width-x)/2
y=(screen.height-y)/2
window.moveTo x,y
document.title="演示"
end function
set ow=createobject("wscript.shell")
function Film_onclick
Msgbox "这个按钮想让我做什么呢?"
' ow.run "\\n03f89\share\FilM.xls"
end function
function Music_onclick
Msgbox "这个按钮想让我做什么呢?"
' ow.run "\\n03f89\share\music.xls"
end function
function Sex_onclick
Msgbox "这个按钮想让我做什么呢?"
' ow.run "\\n03f89\share\Sex.xls"
end function
function Food_onclick
Msgbox "这个按钮想让我做什么呢?"
' ow.run "\\n03f89\share\Food.xls"
end function
function Play_game_onclick
Msgbox "这个按钮想让我做什么呢?"
' ow.run "\\n03f89\share\Play-game.xls"
end function
function Post_onclick
Msgbox "这个按钮想让我做什么呢?"
' ow.run "\\n03f89\share\Post.xls"
end function
function Run(StrPath)
ow.run(StrPath)
End Function
</script>
<style>
input{background:#9ed048;}
p{font-size:15;}
</style>
<body scroll=no bgcolor=#48c0a3>
<p>
请输入要运行的程序:<br><input name=exe style="height:20px;width:200px;" type=text value="regedit">
<BUTTON class=button style="height:20px;width:50px;position: relative;">确定</BUTTON>
<br><br>
<BUTTON class=button style="height:20px;width:50px;position: relative;">记事本</BUTTON>
<br><br><br>
</p>
<center>
<p>
此菜单将为您演示hta的功能<br><strong>请选择:</strong>
<br><br>
<input type=button id=Film style="height:26px;width:150px;position: relative;" value="Film">
<br><br>
<input type=button id=Music style="height:26px;width:150px;position: relative;" value="Music">
<br><br>
<input type=button id=Sex style="height:26px;width:150px;position: relative;" value="Sex">
<br><br>
<input type=button id=Food style="height:26px;width:150px;position: relative;" value= "Food">
<br><br>
<input type=button id=Play_game style="height:26px;width:150px;position: relative;" value="Play game">
<br><br>
<input type=button id=Post style="height:26px;width:150px;position: relative;" value="Post">
<br><br><br>
<input type=button style="height:26px;width:150px;position: relative;" value="退出 "
onclick=window.close()>
<br><br>
</p>
|
|