新 IE 中的 Vbscript 检测按钮 window
Vbscript detect button in an new IE window
我有一个打开网页的 vbscript,然后单击一个按钮。该按钮在新的 window 上打开一个新的弹出网页(注意:window 而不是选项卡)。
我想在我的脚本按下按钮并打开一个新 window 后,检测并单击那个新 window 中名为 id="pagesHeaderLikeButton"
的按钮,然后关闭那个 [=22] =].
到目前为止我的脚本:
Set IE = createobject("internetexplorer.application")
strURL = "website"
Do While True
IE.navigate strURL
IE.Visible = true
Do While (IE.Busy Or IE.READYSTATE <> 4)
WScript.Sleep 1000
Loop
Set Popupbutton = IE.Document.GetElementsByClassName("single_like_button btn3-wrap")
for each button in Popupbutton
button.click
WScript.Sleep 5000
exit for
objWindow.Quit
WScript.Sleep 5000
next
Loop
还要注意。我想这样做是因为弹出窗口 window 总是会有一个新的 url.
For Each wnd In CreateObject("Shell.Application").Windows
If InStr(wnd.Name,"Internet") Then
if InStr(wnd.Document.URL,"facebook.com") Then
Set IE2 = wnd
Exit For
End If
End If
Next
以上脚本将找到任何打开的带有 URL: facebook.com/*** 的 IE,并将 IE2 设置为打开的 IE。
所以按下按钮:
Set Butlike = IE2.Document.getElementsById("pagesHeaderLikeButton")
For Each btn In Butlike
button.click
Next
我有一个打开网页的 vbscript,然后单击一个按钮。该按钮在新的 window 上打开一个新的弹出网页(注意:window 而不是选项卡)。
我想在我的脚本按下按钮并打开一个新 window 后,检测并单击那个新 window 中名为 id="pagesHeaderLikeButton"
的按钮,然后关闭那个 [=22] =].
到目前为止我的脚本:
Set IE = createobject("internetexplorer.application")
strURL = "website"
Do While True
IE.navigate strURL
IE.Visible = true
Do While (IE.Busy Or IE.READYSTATE <> 4)
WScript.Sleep 1000
Loop
Set Popupbutton = IE.Document.GetElementsByClassName("single_like_button btn3-wrap")
for each button in Popupbutton
button.click
WScript.Sleep 5000
exit for
objWindow.Quit
WScript.Sleep 5000
next
Loop
还要注意。我想这样做是因为弹出窗口 window 总是会有一个新的 url.
For Each wnd In CreateObject("Shell.Application").Windows
If InStr(wnd.Name,"Internet") Then
if InStr(wnd.Document.URL,"facebook.com") Then
Set IE2 = wnd
Exit For
End If
End If
Next
以上脚本将找到任何打开的带有 URL: facebook.com/*** 的 IE,并将 IE2 设置为打开的 IE。
所以按下按钮:
Set Butlike = IE2.Document.getElementsById("pagesHeaderLikeButton")
For Each btn In Butlike
button.click
Next