Using a VB.net program to click the mouse on certain coordinates

I am trying to use mouse commands like...

Mouse.Move.SetMousePosition(150,120)
Mouse.Click.LeftDown()
Mouse.Click.LeftUp()

In a VB.NET program, but it does not recognize Mouse.Click or Mouse.Move.  Do I need to add a reference?  I tried adding "Imports Mouse", but that did not work.
BrianAsked:
Who is Participating?
 
BrianAuthor Commented:
I think this is what I need...
Public Class Form1
    Public Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Long)
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Me.Cursor = New Cursor(Cursor.Current.Handle)
        Cursor.Position = New Point(150, 150)
        mouse_event(&H2)
        mouse_event(&H4)
        Cursor.Position = New Point(200, 200)
        mouse_event(&H2)
        mouse_event(&H4)
    End Sub
End Class

Open in new window

0
 
cmdolcetCommented:
Do you have any code you can share?
0
 
Éric MoreauSenior .Net ConsultantCommented:
What are you trying to do exactly? You probably cannot control the mouse as you want.
0
 
BrianAuthor Commented:
All I want to do is move the mouse to a certain coordinate on the screen and click the left mouse button.  I'm trying to use this code I found on YouTube...
https://www.youtube.com/watch?v=eHZd0MvwmnQ
0
 
BrianAuthor Commented:
Tested the code and it works.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.