How do I simulate a right mouse click on webbrowser control based on a coordinates?
Simulate a mouse click on webbrowser control
Page 1 of 113 Replies - 6131 Views - Last Post: 27 June 2012 - 11:54 AM
Replies To: Simulate a mouse click on webbrowser control
#2
Re: Simulate a mouse click on webbrowser control
Posted 07 March 2011 - 02:03 PM
This should work:
Change 20,20 to wherever the element is on the webpage.
Dim ele As HtmlElement = WebBrowser1.document.GetElementFromPoint(20, 20)
ele.InvokeMember("click")
Change 20,20 to wherever the element is on the webpage.
#3
Re: Simulate a mouse click on webbrowser control
Posted 24 June 2012 - 06:04 AM
Jack Eagles1, on 07 March 2011 - 02:03 PM, said:
This should work:
Change 20,20 to wherever the element is on the webpage.
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
#4
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
#5
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?
#6
Re: Simulate a mouse click on webbrowser control
Posted 25 June 2012 - 09:05 AM
um, i have put the code in which is
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.
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.
#7
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.
#8
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.
#9
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.
#10
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.
#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.
#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
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
#13
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.
Stop copying and start trying to understand.
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.
#14
Re: Simulate a mouse click on webbrowser control
Posted 27 June 2012 - 11:54 AM
thanks all sorted, now cheers for the help
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote





|