Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
Dim elements As HtmlElementCollection = WebBrowser1 And WebBrowser2.Document.All
For Each webpageelement As HtmlElement In elements
If webpageelement.GetAttribute("id") = "skip_ad_button" Then
webpageelement.InvokeMember("click")
End If
Next
End Sub
我想将2个webbrowser放在同一个timer3中![在此处输入图片说明] [1]
答案 0 :(得分:1)
如果您创建HtmlElementCollection
数组,则可以使用此代码同时控制多个文档:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim elements As HtmlElementCollection() = New HtmlElementCollection() {WebBrowser1.Document.All, WebBrowser2.Document.All}
For Each webpageelementcollection As HtmlElementCollection In elements
For Each webpageelement As HtmlElement In webpageelementcollection
If webpageelement.GetAttribute("id") = "ELEMENT_ID" Then
webpageelement.InvokeMember("click")
End If
Next
Next
End Sub