当前位置: 代码迷 >> vbScript >> VBS怎么获得窗口句柄
  详细解决方案

VBS怎么获得窗口句柄

热度:10657   发布时间:2013-02-26 00:00:00.0
VBS如何获得窗口句柄
最近任务要求写一段VBS程序经过一定的处理之后打开一个IE窗口。

当第二次执行这段VBS程序的时候,如果先前(第一次执行)的窗口没有被关闭需要在先前的窗口中打开。

这里就需要得到打开IE窗口的句柄,不知道该如何获得,高人指点一下啊。

------解决方案--------------------------------------------------------


<button onclick= "vbs:openWin "> open </button>
<input type= "hidden " id= "hhh " value= "0 ">
<script language= "vbscript ">
dim win
dim a
sub openWin()
hhh.value=int(hhh.value)+1
if isobject(win) then
win.document.body.innerHTML=win.opener.document.getElementById( "hhh ").value +1
else
set win=window.open( "about:blank ")
win.document.body.innerHTML =win.opener.document.getElementById( "hhh ").value +1
end if
end sub


</script>
------解决方案--------------------------------------------------------
帮顶
------解决方案--------------------------------------------------------
OPEN的时候指定窗口名称就可以了:
<script language= "vbscript ">
window.open "http://community.csdn.net/Expert/topic/5324/5324568.xml?temp=.9649622 ", "csdn "
</script>
------解决方案--------------------------------------------------------
目前只能做到这样的情况

<input type=button onclick= "vbs:openWin " value=open>
<script language= "vbscript ">
dim win
dim a
Set win = Nothing
sub openWin()

If win Is Nothing Then
set win=window.open( "about:blank ")
win.document.body.innerHTML= "First New "
else
If win.closed Then
set win=window.open( "about:blank ")
win.document.body.innerHTML= "New "
Else
win.focus
win.document.body.innerHTML= "Exists "
End If
end if

end sub


</script>
------解决方案--------------------------------------------------------
.Write " option= 'toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width= '+window.screen.width + ',height= '+window.screen.height " & vbcrlf
  相关解决方案