vb6:通过代码单击 HTMLDocument 上的按钮并等待页面加载

发布于 2024-09-29 01:53:40 字数 716 浏览 1 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情深缘浅 2024-10-06 01:53:40
  • 使用 vb.net

  • wBrowser 是一个 webbroser 对象

    当 wBrowser.ReadyState <> WebBrowserReadyState.Complete
         应用程序.DoEvents()
    结束时
    
  • use vb.net

  • wBrowser is a webbroser object

    While wBrowser.ReadyState <> WebBrowserReadyState.Complete
         Application.DoEvents()
    End While
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文