Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" ( _
ByVal hwnd As IntPtr, _
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As Int32) As Int32
Public Declare Function WindowFromPoint Lib "user32" ( _
ByVal stPoint As Point) As IntPtr
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Function ScreenshotForm() As Bitmap
Dim bmp As New Bitmap(Me.Width, Me.Height)
Using g As Graphics = Graphics.FromImage(bmp)
g.CopyFromScreen(Me.Location, Point.Empty, Me.Size)
End Using
Return bmp
End Function
Private Sub MoveMousetoPixel(ByVal Clr As Color)
Dim BMP As Bitmap = ScreenshotForm()
For x As Integer = 1 To BMP.Width - 1
For y As Integer = 1 To BMP.Height - 1
If BMP.GetPixel(x, y).ToArgb = Clr.ToArgb Then
ax.Text = x + Me.Location.X
Ay.Text = y + Me.Location.Y
Exit Sub
End If
Next
Next
End Sub