Results 1 to 4 of 4

Thread: [RESOLVED] [2008] Web Browser (Click Item) (Got code from code bank, need help)

  1. #1

    Thread Starter
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Resolved [RESOLVED] [2008] Web Browser (Click Item) (Got code from code bank, need help)

    Hey, I've found some code (by Kleinma I think), which clicks a web browser button, I've successfully found the web browser button.. however I need to, click it via code, or move the mouse there and force it to click..

    If anyone knows how to do this via code, I'd appreciate it a lot, otherwise, I need to find a way to set the mouse's position, and also make it click.

    I also need to figure out how to get the position of the button on the screen (iX in my code is showing as 168, (I have 800*600 form size))
    iX value is 168, is off by about 30-40, and iY (which is in my newer code), is off by about 200-300

    My Code:

    Code:
        Private Sub bClick_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bClick.Click
            Dim curWebForm As HtmlElement = Nothing
            If wbBrowser.Document.Forms.Count > 0 Then
                curWebForm = wbBrowser.Document.Forms.Item(0)
                Dim hecCollection As HtmlElementCollection = curWebForm.All
                For Each heElement As HtmlElement In hecCollection
                    If heElement.Id = "cmdClickMe" Then
                        Dim heParent As HtmlElement = heElement.Parent
                        Dim iX As Integer = 0
                        While 0 < 1
                            iX += heParent.OffsetRectangle.X
                            heParent = heParent.Parent
                            If heParent Is Nothing Then
                                Exit While
                            End If
                        End While
                        rtbBox.AppendText("iX " & iX & ControlChars.NewLine)
                    End If
                Next heElement
                'DirectCast(GetCurrentWebForm.item("cmdClickMe", 0), mshtml.HTMLButtonElement).click()
            End If
        End Sub
    If anyone can help, I'd appreciate it.

    Cheers
    Icyculyr
    Last edited by Icyculyr; May 27th, 2008 at 05:44 AM.

  2. #2
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: [2008] Web Browser (Click Item) (Got code from code bank, need help)

    Hi,

    You could use this for the location of your button:

    vb Code:
    1. bClick.Location = New point(168, 300)

    Wkr,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  3. #3

    Thread Starter
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: [2008] Web Browser (Click Item) (Got code from code bank, need help)

    Erm thanks, but that's not the problem..

    The button is in the web page (html button), and I need to get it's position, bClick, is the button i'm clicking, to try and get the html button's position accurately..

    Cheers
    Icyculyr

  4. #4

    Thread Starter
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: [2008] Web Browser (Click Item) (Got code from code bank, need help)

    I've found it, HtmlElement has a member called "InvokeMember, I passed "click" as it's first parameter, and it clicked the button!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width