Imports System
Imports System.Drawing
Imports System.Windows.Forms


Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click




 End Sub
End Class

Hello, I have a textbox and I have a button. Okey, when the button is clicked I want my mouse to go and click a certain position on my screen. How can I do that using Visual basic 2008 express??
whats the simple code for it? thank you very much. I am in need to use it for a big project.

A begginer in vb.net, I am moving from using c/java

Imports System
Imports System.Drawing
Imports System.Windows.Forms


Public Class Form1




    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Windows.Forms.Cursor.Position = New System.Drawing.Point(200, Button1.Location.Y + Me.Location.Y + 30)



    End Sub





End Class

By using that code, I am moving the mouse to a certain position on my screen once the button is clicked.

how can i make the mouse click on that particular position now???thank u

Thats depends... are you moving the mouse to another control on your form? if so you could just raise the click event for this control.

lets say you move the mouse to textbox1 then you just do : textbox1_Click(me, new system.eventargs) ofcourse this event have to exist.
If there is no control where you move the mouse to then just raise the click event for the form.

I try to compile the code given above, but a warning messages "invalid outside precedure" come out what's that means?

can you give a step by step instruction on how to apply that code into vb.
I'm a beginner of vb and i don't know what to do.

This article has been dead for over six months. Start a new discussion instead.