【发布时间】:2015-06-13 15:56:42
【问题描述】:
我尝试编写一个脚本来检测在 Facebook 上打开的 IE 窗口并点击 Like 按钮。 假设我打开了 10 个 IE。只有其中一个出现在 Facebook 的页面上。 我想让我的脚本检测到那个 IE 窗口,点击这个按钮:
IE.Document.getElementById("pagesHeaderLikeButton")
(上面的按钮是Like按钮)
并关闭该 IE 窗口。
我尝试通过以下方式获取该 IE 窗口:
For Each wnd In CreateObject("Shell.Application").Windows
If InStr(1, wnd.FullName, "iexplore.exe", vbTextCompare) > 0 Then
Set IE = wnd
Exit For
End If
Next
但这只会将我的 VBscript 设置为第一个打开的 IE,它不会找到 Facebook 窗口。
我试过了:
Dim objInstances, item
Set objInstances = CreateObject("Shell.Application").windows
For Each item In objInstances
If Item.Name Like "*Internet*" And Item.document.URL Like "*facebook.com*" Then
IE.Document.getElementById("pagesHeaderLikeButton").Click
End If
Next
但我得到“未定义子或函数”
【问题讨论】:
标签: facebook internet-explorer vbscript