VB的webbrowser控件 使用问题
是否能用VB指令,让已经有按钮的webbrowser控件,按下按钮呢?能实现的话怎么操作呢?谢谢各位了。就是在VB里有一个WEBBROWSER控件,里面有一个提交按扭,如...
是否能用VB指令,让已经有按钮的webbrowser控件,按下按钮呢?能实现的话怎么操作呢?谢谢各位了。
就是在VB里有一个WEBBROWSER控件,里面有一个提交按扭,如果用VB代码点击这个按钮?可行吗?谢谢了 展开
就是在VB里有一个WEBBROWSER控件,里面有一个提交按扭,如果用VB代码点击这个按钮?可行吗?谢谢了 展开
4个回答
展开全部
模拟
采用WebBrowser控件,以及模拟鼠标操作的API,首先由WebBrowser打开网站页面,然后移动到广告显示的位置,,打开的内容在第二个WebBrowser中显示,然后
下面就是全部的代码.
窗体上有两个COMMAND和两个WebBrowser,'对于API的调用
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
dim x As Integer, y As Integer
Private Sub Command1_Click()
SetCursorPos x, y '模拟鼠标移动到指定坐标(相对于屏幕)
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 '模拟鼠标左键按下
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 '模拟鼠标左键抬起
End Sub
数字
Dim vDoc, vTag
Set vDoc = WebBrowser1.Document
For i = 0 To vDoc.All.length - 1 '检测所有标签
If UCase(vDoc.All(i).tagName) = "BUTTON" Then '找到input标签
Set vTag = vDoc.All(i)
vTag.Type = "submit" And vTag.Name = "replysubmit" Then 'And vTag.Value = "replysubmit"
vTag.Click
End If
Next i
下面是现在DZ论坛的按钮代码(红色部份)
<label>标题
<input type="text" name="subject" value="" tabindex="1"> </label> </h5>
<p> <label>内容 </label>
<textarea rows="7" cols="80" class="autosave" name="message" id="message" onKeyDown="ctlent(event);" tabindex="2"> </textarea>
</p>
<p class="btns">
<button type="submit" name="replysubmit" id="postsubmit" value="replysubmit" tabindex="3">发表帖子 </button>[完成后可按 Ctrl+Enter 发布]
采用WebBrowser控件,以及模拟鼠标操作的API,首先由WebBrowser打开网站页面,然后移动到广告显示的位置,,打开的内容在第二个WebBrowser中显示,然后
下面就是全部的代码.
窗体上有两个COMMAND和两个WebBrowser,'对于API的调用
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
dim x As Integer, y As Integer
Private Sub Command1_Click()
SetCursorPos x, y '模拟鼠标移动到指定坐标(相对于屏幕)
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 '模拟鼠标左键按下
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 '模拟鼠标左键抬起
End Sub
数字
Dim vDoc, vTag
Set vDoc = WebBrowser1.Document
For i = 0 To vDoc.All.length - 1 '检测所有标签
If UCase(vDoc.All(i).tagName) = "BUTTON" Then '找到input标签
Set vTag = vDoc.All(i)
vTag.Type = "submit" And vTag.Name = "replysubmit" Then 'And vTag.Value = "replysubmit"
vTag.Click
End If
Next i
下面是现在DZ论坛的按钮代码(红色部份)
<label>标题
<input type="text" name="subject" value="" tabindex="1"> </label> </h5>
<p> <label>内容 </label>
<textarea rows="7" cols="80" class="autosave" name="message" id="message" onKeyDown="ctlent(event);" tabindex="2"> </textarea>
</p>
<p class="btns">
<button type="submit" name="replysubmit" id="postsubmit" value="replysubmit" tabindex="3">发表帖子 </button>[完成后可按 Ctrl+Enter 发布]
展开全部
不明白什么意思
参考资料: 如果您的回答是从其他地方引用,请表明出处
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
他是用代码来实现的啊,而不是那样点击 的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim vDoc, vTag
Set vDoc = WebBrowser1.Document
For i = 0 To vDoc.All.length - 1 '检测所有标签
If UCase(vDoc.All(i).tagName) = "BUTTON" Then '找到input标签
Set vTag = vDoc.All(i)
vTag.Type = "submit" And vTag.Name = "replysubmit" Then 'And vTag.Value = "replysubmit"
vTag.Click
End If
Next i
Set vDoc = WebBrowser1.Document
For i = 0 To vDoc.All.length - 1 '检测所有标签
If UCase(vDoc.All(i).tagName) = "BUTTON" Then '找到input标签
Set vTag = vDoc.All(i)
vTag.Type = "submit" And vTag.Name = "replysubmit" Then 'And vTag.Value = "replysubmit"
vTag.Click
End If
Next i
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询