13 Replies - 11478 Views - Last Post: 27 June 2012 - 11:54 AM Rate Topic: -----

#1 duanebytes@live.com  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 06-March 11

Simulate a mouse click on webbrowser control

Posted 06 March 2011 - 05:41 AM

How do I simulate a right mouse click on webbrowser control based on a coordinates?
Is This A Good Question/Topic? 0
  • +

Replies To: Simulate a mouse click on webbrowser control

#2 Jack Eagles1  Icon User is offline

  • Pugnacious Penguin (inspired by no2pencil)
  • member icon

Reputation: 183
  • View blog
  • Posts: 1,152
  • Joined: 10-December 08

Re: Simulate a mouse click on webbrowser control

Posted 07 March 2011 - 02:03 PM

This should work:

Dim ele As HtmlElement = WebBrowser1.document.GetElementFromPoint(20, 20)
ele.InvokeMember("click")



Change 20,20 to wherever the element is on the webpage.
Was This Post Helpful? 0
  • +
  • -

#3 bigcake  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 24-June 12

Re: Simulate a mouse click on webbrowser control

Posted 24 June 2012 - 06:04 AM

View PostJack Eagles1, on 07 March 2011 - 02:03 PM, said:

This should work:

Dim ele As HtmlElement = WebBrowser1.document.GetElementFromPoint(20, 20)
ele.InvokeMember("click")



Change 20,20 to wherever the element is on the webpage.



How do you work out where an element is on an webpage (meaning is there a software or...) how can you find the location (cordinates) of the element
Was This Post Helpful? 0
  • +
  • -

#4 PNJLj  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 178
  • Joined: 18-May 09

Re: Simulate a mouse click on webbrowser control

Posted 24 June 2012 - 02:25 PM

TextBox1.Text = "x  Position = " & MousePosition.X & vbCrLf & "y  Position = " & MousePosition.Y


Place this code within a timer control and you will see the X, Y co-ordinates. You may also want to change the Timer Properties to 1 instead of 100 but shouldn't really make any difference.
Once you move the mouse to the Area you want to click in then write down the X, Y Co-ordinates and the change them with the 20/20 ones.

PS, its also polite to say thanks.

This post has been edited by PNJLj: 24 June 2012 - 02:26 PM

Was This Post Helpful? 0
  • +
  • -

#5 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,499
  • Joined: 16-March 11

Re: Simulate a mouse click on webbrowser control

Posted 25 June 2012 - 07:09 AM

There is also grabbing the element itself, but can I ask why you need this?
Was This Post Helpful? 0
  • +
  • -

#6 bigcake  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 24-June 12

Re: Simulate a mouse click on webbrowser control

Posted 25 June 2012 - 09:05 AM

um, i have put the code in which is

Dim ele As HtmlElement = WebBrowser1.document.GetElementFromPoint(20, 200)
ele.InvokeMember("click")


and it has come up with an error which is

value of type 'interger' cannot be converted to system.drawing.point

and also

Too many arguments to public function GetElementFromPoint (point as System.Drawing.Point) As system.Windows.Forms.HtmlElement.

Has anyone got any ideas on how to rectify these error

thanks.
Was This Post Helpful? 0
  • +
  • -

#7 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,499
  • Joined: 16-March 11

Re: Simulate a mouse click on webbrowser control

Posted 25 June 2012 - 09:40 AM

Which is pretty straight forward. You're trying to pass an integer into a point. This is why ya don't want to copy and paste.
Was This Post Helpful? 0
  • +
  • -

#8 bigcake  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 24-June 12

Re: Simulate a mouse click on webbrowser control

Posted 25 June 2012 - 10:05 AM

so, can you help me on what to put then please.
Was This Post Helpful? 0
  • +
  • -

#9 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,499
  • Joined: 16-March 11

Re: Simulate a mouse click on webbrowser control

Posted 25 June 2012 - 10:47 AM

Create a point variable and pass into it's arguments the coordinates, then pass the GetElementFromPoint method the point instead.
Was This Post Helpful? 0
  • +
  • -

#10 bigcake  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 24-June 12

Re: Simulate a mouse click on webbrowser control

Posted 25 June 2012 - 11:56 AM

so please can you help me with the code please.
Was This Post Helpful? 0
  • +
  • -

#11 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,499
  • Joined: 16-March 11

Re: Simulate a mouse click on webbrowser control

Posted 25 June 2012 - 03:39 PM

Dim NewPoint as New Point(20, 200)



Pass that new point into the getelementfrompoint method instead of the coordinates.
Was This Post Helpful? 0
  • +
  • -

#12 bigcake  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 24-June 12

Re: Simulate a mouse click on webbrowser control

Posted 26 June 2012 - 08:32 AM

Ok Thanks but still i have the error with this code

Dim NewPoint As New Point (20, 200)

Dim ele As HtmlElement = WebBrowser1.document.GetElementFromPoint(20, 200)
ele.InvokeMember("click"

and i still get the error's

Value of type 'Interger' cannot be converted to 'system.Drawing.Point

and

Too Many arguments to 'public function GetElementFromPoint.


Please help me further thank you in advance
Was This Post Helpful? 0
  • +
  • -

#13 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,499
  • Joined: 16-March 11

Re: Simulate a mouse click on webbrowser control

Posted 26 June 2012 - 11:00 AM

Read exactly what I said and stop just copying and pasting. Put that point into the
Methods arguments, does that make sense? Grab the Point, and instead of passing 20, 200 pass the POINT into the method.

Dim k as new point(20, 200)

Dim workingsample as htmlelement = Mysamplemethod(k)




Stop copying and start trying to understand.
Was This Post Helpful? 0
  • +
  • -

#14 bigcake  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 24-June 12

Re: Simulate a mouse click on webbrowser control

Posted 27 June 2012 - 11:54 AM

thanks all sorted, now cheers for the help :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1