我有这个 VBS 脚本来创建消息框。
x=msgbox("The message" ,6, "Title")
但如果我运行另一个带有不同消息的脚本,它会将其放在顶部。使用以下代码从批处理文件调用 vbs:
@echo off & %temp%\message.vbs
我的问题是如何制作它,以便它替换消息而不是将其放在顶部。
VBScript 允许替换窗口中的文本,甚至可以来自不同的脚本。使用 HTA,无临时文件。
showmessage "Time is " & now
sub showmessage(text)
' source http://forum.script-coding.com/viewtopic.php?pid=75356#p75356
dim shellwnd, proc, wnd
on error resume next
for each shellwnd in createobject("Shell.Application").windows
set wnd = shellwnd.getproperty("messagewindow")
if err.number = 0 then
wnd.document.body.innerhtml = text
exit sub
end if
err.clear
next
do
set proc = createobject("WScript.Shell").exec("mshta ""about:<html><head><script>moveTo(-32000,-32000);</script><hta:application id=app border=dialog minimizebutton=no maximizebutton=no scroll=no showintaskbar=yes contextmenu=no selection=no innerborder=no /><object id='shellwindow' classid='clsid:8856F961-340A-11D0-A96B-00C04FD705A2'><param name=RegisterAsBrowser value=1></object><script>shellwindow.putproperty('messagewindow',document.parentWindow);</script></head></html>""")
do
if proc.status > 0 then exit do
for each shellwnd in createobject("Shell.Application").windows
set wnd = shellwnd.getproperty("messagewindow")
if err.number = 0 then
with wnd
.document.title = "Message"
.document.body.style.background = "buttonface"
.document.body.style.fontfamily = "verdana"
.document.body.style.fontsize = "0.7em"
.document.body.innerhtml = text
.resizeto 300, 150
.moveto 200, 200
end with
exit sub
end if
err.clear
next
loop
loop
end sub
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)