Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generated a mousclick from code

Status
Not open for further replies.

Herby1976

Programmer
May 7, 2009
11
BE
I want to generate a left mousclick event from VB code.
Sombody a idee how to do it?


Thanks
 
Generate a left click where? Within your application? Wherever the mouse is at the time? Another application?

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
If you need to perform a click to a button, then:

Button1.PerformClick

Regards.
 
It's in the form in the webbrowser. Then i can do some reapeating stuf with the program that i do now manualy.
 
Is this what you are trying to do:
Code:
Dim elm As HtmlElement = WebBrowser1.Document.All.GetElementsByName("Button1")(0)
elm.RaiseEvent("onclick")
?
 
Try to autoclic in the webpage. Only the move works for xpos but not the ypos, there it's using all the time 0. Use this code:

Public Declare Sub Mouse_Event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Long, ByVal dx As Int32, ByVal dy As Int32, ByVal cButtons As Int32, ByVal dwExtraInfo As Long)

Public Const MouseEventF_Leftdown = &H2
Public Const MouseEventF_Leftup = &H4
Public Const MouseEventF_Move = &H8001

Mouse_Event(MouseEventF_Move , Xpos, Ypos, 0&, 0&)
Mouse_Event(MouseEventF_Leftdown , Xpos, Ypos, 0&, 0&)
Mouse_Event(MouseEventF_Leftup , Xpos, Ypos, 0&, 0&)
 
Got it working whit this code. But it works only with framework 3.0 or higher. First test i got only the 2.0 .net. Thnaks for the advice
 
I got it working on framework 2 either.
Glad to be of any help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top