Hello!
----------------------------------------
I'm new to this forum and I would like to contribute something that might be helpful to a good amount of people!
The code I am going to show you will tell you how to control the exact position of your mouse (On your screen of course :P)
--------------------------------------------------------
The code below is the entire source code, if you want to only take certain parts.
Code
 Module Mouse
VB.NET
 Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
VB.NET
    Public Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
VB.NET
    Public Declare Function GetCursorPos Lib "user32" (ByVal lpPoint As POINTAPI) As Long
Code
    Public Const MOUSEEVENTF_LEFTDOWN = &H2
Code
    Public Const MOUSEEVENTF_LEFTUP = &H4
Code
    Public Const MOUSEEVENTF_MIDDLEDOWN = &H20
Code
    Public Const MOUSEEVENTF_MIDDLEUP = &H40
Code
    Public Const MOUSEEVENTF_RIGHTDOWN = &H8
Code
    Public Const MOUSEEVENTF_RIGHTUP = &H10
Code
    Public Const MOUSEEVENTF_MOVE = &H1
Code
    Public Structure POINTAPI
Code
        Dim x As Long
Code
     Dim y As Long
Code
    End Structure
Code
    Public Function GetX() As Long
Code
        Dim n As POINTAPI
Code
        GetCursorPos(n)
Code
        GetX = n.x
Code
    End Function
Code
    Public Function GetY() As Long
Code
        Dim n As POINTAPI
Code
        GetCursorPos(n)
Code
        GetY = n.y
Code
    End Function
Code
Code
    Public Sub LeftClick()
Code
        LeftDown()
Code
        LeftUp()
Code
    End Sub
Code
    Public Sub LeftDown()
Code
        mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
Code
    End Sub
Code
    Public Sub LeftUp()
Code
        mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
Code
    End Sub
Code
    Public Sub MiddleClick()
Code
        MiddleDown()
Code
        MiddleUp()
Code
    End Sub
Code
    Public Sub MiddleDown()
Code
        mouse_event(MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0)
Code
    End Sub
Code
    Public Sub MiddleUp()
Code
        mouse_event(MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0)
Code
    End Sub
Code
    Public Sub RightClick()
Code
        RightDown()
Code
        RightUp()
Code
    End Sub
Code
    Public Sub RightDown()
Code
        mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
Code
    End Sub
Code
    Public Sub RightUp()
Code
        mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
Code
    End Sub
VB.NET
    Public Sub MoveMouse(ByVal xMove As Long, ByVal yMove As Long)
Code
        mouse_event(MOUSEEVENTF_MOVE, xMove, yMove, 0, 0)
Code
    End Sub
VB.NET
    Public Sub SetMousePos(ByVal xPos As Long, ByVal yPos As Long)
Code
        SetCursorPos(xPos, yPos)
Code
    End Sub
Code
End Module
 


That will just about do it, there isn't any Reference's to made nor are there any imports :) Just copy and paste!

Here is an example on how to use it:
Code
'This will get the coordinates for the exact center of the screen
VB.NET
	Dim intX As Integer = Screen.PrimaryScreen.Bounds.Width
        Dim intY As Integer = Screen.PrimaryScreen.Bounds.Height
Code
'Moves the mouse to the center of the screen and a little bit down.
Code
        Mouse.SetMousePos(intX \ 2, intY \ 2 + 90)
Code
'Click's on the coordinates
Code
	Mouse.LeftClick()

I hope that this will be useful to you in anyway! I will also use this as some sort of a database (Just in case I loose it :P)

- Scott Pendleton