使用VBscript获取活动IE8选项卡的URL
如何调整下面的vbscript代码,以提供IE8中活动选项卡的URL?我是否可以使用AppActivate方法来聚焦窗口并获取URL,而不是为Internet Explorer创建对象并导航到已声明的网站?注意:vbscript将在用户的本地计算机上使用,而不会嵌入其他网页。谢谢使用VBscript获取活动IE8选项卡的URL,url,vbscript,internet-explorer-8,Url,Vbscript,Internet Explorer 8,如何调整下面的vbscript代码,以提供IE8中活动选项卡的URL?我是否可以使用AppActivate方法来聚焦窗口并获取URL,而不是为Internet Explorer创建对象并导航到已声明的网站?注意:vbscript将在用户的本地计算机上使用,而不会嵌入其他网页。谢谢 Set IE=CreateObject("InternetExplorer.application") IE.Visible=false IE.Navigate "http://www.google.com" Do
Set IE=CreateObject("InternetExplorer.application")
IE.Visible=false
IE.Navigate "http://www.google.com"
Do While IE.Busy
wScript.sleep 1000
Loop
WScript.Echo IE.Document.URL
如果试图获取活动实例,则不应使用
CreateObject
<代码>获取对象在这里也帮不了你。您需要使用Shell.Application
对象的Windows
集合
Set Shell = CreateObject("Shell.Application")
For Each Window In Shell.Windows
' Make sure it's an Internet Explorer (iexplore) window...
If InStr(1, Window.FullName, "iexplore.exe", vbTextCompare) > 0 Then
' Display the URL of the current page...
MsgBox Window.LocationUrl
End If
Next