vb6:通过代码单击 HTMLDocument 上的按钮并等待页面加载
我正在使用 mshtml.tlb 来加载/解析 html,我想扩展它以通过代码单击元素。问题是在例如之后捕获加载过程。单击了一个按钮。 在我的具体情况下,我想执行用户登录。
这是我的代码:
Dim WithEvents m_doc As HTMLDocument
' load page
Set m_docNU = New HTMLDocument
Set m_doc = m_docNU.createDocumentFromUrl(m_url, vbNullString)
Do While m_doc.readyState = "loading" Or m_doc.readyState = "interactive"
DoEvents
Loop
set txtUsername = m_doc.getElementById("username")
set txtPasswort = m_doc.getElementById("passwort")
set myButton = m_doc.getElementById("submit")
myButton.click
现在这是一个大问号:如何继续 vb6- 就像“等待页面加载”? 我已经尝试像上面一样使用 do while 循环并检查readyState,但由于某种原因,readyState 在单击按钮后不会改变..
有什么想法吗?
谢谢
ps:有没有更优雅的方法来代替 do while 循环?例如。使用进度条?
i'm using the mshtml.tlb for loading/parsing html and i'd like extend it for clicking elements by code. the problem is trapping the loading-process after eg. a button was clicked.
in my specific case i'd like to perform a user-login.
here's my code:
Dim WithEvents m_doc As HTMLDocument
' load page
Set m_docNU = New HTMLDocument
Set m_doc = m_docNU.createDocumentFromUrl(m_url, vbNullString)
Do While m_doc.readyState = "loading" Or m_doc.readyState = "interactive"
DoEvents
Loop
set txtUsername = m_doc.getElementById("username")
set txtPasswort = m_doc.getElementById("passwort")
set myButton = m_doc.getElementById("submit")
myButton.click
now here's the big question mark: how to continue vb6- like "wait until page is loaded"?
i've tried as above using a do while-loop and checking the readyState, but for some reason the readyState doesn't change after clicking the button ..
any ideas?
thanks
ps: is there a more elegant way instead of the do while-loop? eg. using a progressbar?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 vb.net
wBrowser 是一个 webbroser 对象
use vb.net
wBrowser is a webbroser object