求vb程序点击webbrowser中的一个坐标点x,y的代码.
事情是这样的,窗体上有一个command1,一个webbrowser1,预先设置webbrowser内的x,y的值分别为500,600form_load中有代码:WebB...
事情是这样的,窗体上有一个command1,一个webbrowser1,预先设置webbrowser内的x,y的值分别为500,600
form_load中有代码:WebBrowser1.Navigate "http://www.baidu.com"
现在想要实现的效果是:点击command1后,程序会按指定的X,Y的值去点击它在webbrowser中的相应位置。 展开
form_load中有代码:WebBrowser1.Navigate "http://www.baidu.com"
现在想要实现的效果是:点击command1后,程序会按指定的X,Y的值去点击它在webbrowser中的相应位置。 展开
2个回答
展开全部
想点击链接不用这么麻烦,看看下面登录Gmail的例子
所需控件 Name Caption
WebBrowser Wb
TextBox Text1
TextBox Text2
Command Command1 登录
Command Command1 退出
Dim flag As Boolean
Private Sub Command1_Click()
Dim vDoc, vTag
Dim i As Integer
If flag = False Then
MsgBox "请稍等。。。"
Exit Sub
End If
Set vDoc = Wb.Document
For i = 0 To vDoc.All.length - 1
If UCase(vDoc.All(i).tagName) = "INPUT" Then
Set vTag = vDoc.All(i)
If vTag.Type = "text" Or vTag.Type = "password" Then
'List1.AddItem vTag.Name
Select Case vTag.Name
Case "Email"
vTag.Value = Text1.Text
Case "Passwd"
vTag.Value = Text2.Text
End Select
ElseIf vTag.Type = "submit" Then
vTag.Click '注意这里,这就是单击了,不用找坐标
End If
End If
Next i
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim URL As String
On Error Resume Next
URL = "http://mail.google.com"
Wb.Navigate URL
StatusBar1.Panels(1).Text = "正在打开http://mail.google.com"
End Sub
Private Sub wb_DocumentComplete(ByVal pDisp As Object, URL As Variant)
StatusBar1.Panels(1).Text = "完毕"
flag = True
End Sub
所需控件 Name Caption
WebBrowser Wb
TextBox Text1
TextBox Text2
Command Command1 登录
Command Command1 退出
Dim flag As Boolean
Private Sub Command1_Click()
Dim vDoc, vTag
Dim i As Integer
If flag = False Then
MsgBox "请稍等。。。"
Exit Sub
End If
Set vDoc = Wb.Document
For i = 0 To vDoc.All.length - 1
If UCase(vDoc.All(i).tagName) = "INPUT" Then
Set vTag = vDoc.All(i)
If vTag.Type = "text" Or vTag.Type = "password" Then
'List1.AddItem vTag.Name
Select Case vTag.Name
Case "Email"
vTag.Value = Text1.Text
Case "Passwd"
vTag.Value = Text2.Text
End Select
ElseIf vTag.Type = "submit" Then
vTag.Click '注意这里,这就是单击了,不用找坐标
End If
End If
Next i
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim URL As String
On Error Resume Next
URL = "http://mail.google.com"
Wb.Navigate URL
StatusBar1.Panels(1).Text = "正在打开http://mail.google.com"
End Sub
Private Sub wb_DocumentComplete(ByVal pDisp As Object, URL As Variant)
StatusBar1.Panels(1).Text = "完毕"
flag = True
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询