想知道是否有人可以帮助我进行以下工作?我想:a)查找当前打开的浏览器窗口b)导航到同一标签内的网页(不打开新窗口)
我似乎无法确切找到要查找的内容,如果使用shellexecute,则可以打开浏览器窗口-但是,如果已经打开,则会使用URL打开“新”标签,而不是替换现有的标签网址。
我该如何更换?我当时正在考虑使用EnumProc之类的东西来查找现有的浏览器窗口-但是-我不知道一旦找到窗口句柄我需要做什么来更改url? (这与sendkeys有关吗?或者-我可以使用某些东西专门更改当前浏览器窗口吗?还是取决于浏览器(例如chrome vs MSIE vs firefox)。
尽管最重要-导航到same选项卡中的不同页面,而不是始终打开新实例。
非常感谢!
如果我只是专注于MSIE,我该怎么做?
Windows通过COM公开了一个Shell Windows集合,其中包括Explorer和IE窗口-在后一种情况下,每个选项卡将获得一个窗口,因此:
Dim shApp: Set shApp = CreateObject("Shell.Application")
Dim shWnd: Set shWnd = shApp.Windows()
Dim i As Variant, ie As Object
For i = 0 To shWnd.Count - 1
If shWnd.Item(i).Name = "Internet Explorer" Then
'// got an IE tab
Set ie = shWnd.Item(i)
'// is it the tab we want - based on url
If (LCase$(ie.LocationUrl) = "https://stackoverflow.com/") Then
'// if so send it somewhere else
ie.Navigate2 "http://reddit.com"
End If
End If
Next