Hey, I have this code
Public Class Form1
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)
Private Const MOUSEEVENTF_MOVE As Integer = &H1 ' mouse move
Private Const MOUSEEVENTF_LEFTDOWN As Integer = &H2 ' left button down
Private Const MOUSEEVENTF_LEFTUP As Integer = &H4 ' left button up
Private Const MOUSEEVENTF_RIGHTDOWN As Integer = &H8 ' right button down
Private Const MOUSEEVENTF_RIGHTUP As Integer = &H10 ' right button up
Private Const MOUSEEVENTF_MIDDLEDOWN As Integer = &H20 ' middle button down
Private Const MOUSEEVENTF_MIDDLEUP As Integer = &H40 ' middle button up
Private Const MOUSEEVENTF_WHEEL As Integer = &H800 ' wheel button rolled
Private Const MOUSEEVENTF_ABSOLUTE As Integer = &H8000 ' absolute move
Private m_Target As New Point(200, 150)
Private Sub btnMoveClick_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMoveClick.Click
' Convert the target to absolute screen coordinates.
Dim pt As Point = Me.PointToScreen(m_Target)
' mouse_event moves in a coordinate system where
' (0, 0) is in the upper left corner and
' (65535,65535) is in the lower right corner.
' Convert the coordinates.
Dim screen_bounds As Rectangle = Screen.GetBounds(pt)
Dim x As Integer = CInt(pt.X * CDbl(TextBox1.Text) / screen_bounds.Width)
Dim y As Integer = CInt(pt.Y * CDbl(TextBox2.Text) / screen_bounds.Height)
' Move the mouse.
mouse_event( _
MOUSEEVENTF_ABSOLUTE + _
MOUSEEVENTF_MOVE, _
x, y, 0, 0)
' Click there.
mouse_event( _
MOUSEEVENTF_ABSOLUTE Or _
MOUSEEVENTF_MOVE Or _
MOUSEEVENTF_LEFTDOWN Or _
MOUSEEVENTF_LEFTUP, _
x, y, 0, 0)
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
Label1.Text = "X." & e.X & vbCrLf & "Y." & e.Y
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
That will click coordinates, is there a way to get it to click a pixel colour on the screen?