且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用VB单击网页中的按钮?

更新时间:2023-12-06 12:42:10

如果你给了一个GWT按钮样本来获得帮助,对于那些不熟悉像我这样的GWT的人。

Would be nice if you gave a sample of a GWT button to getting help from for those who does not familiar with GWT like me. I found a page that contains a GWT button (hope) and wrote something based on that.
Consider the following code.

Sub WaitUntil(varObj)
    On Error Resume Next
    Do
        WScript.Sleep 100
    Loop Until Not varObj Is Nothing
    WScript.Sleep 500
End Sub

Dim IE
Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True
    IE.Navigate "http://gwt.google.com/samples/Showcase/Showcase.html#!CwBasicButton"
    WScript.Sleep 500
    WaitUntil IE.Document 'wait until the document is ready
    WaitUntil IE.Document.getElementById("gwt-debug-cwBasicButton-normal") 'wait until the button is initialized
    Dim theButton
    Set theButton = IE.Document.getElementById("gwt-debug-cwBasicButton-normal")
        theButton.Click
        'theButton.fireEvent "onclick" 'another way
Set IE = Nothing