If I put this code in the form, the mouse will be moved once. I want it to "freeze" the mouse at the point that its moved at. If I put code in timer (which it is now), the mouse will keep searching for the color, so the mouse moves around like crazy. How do I change my code so that it will "freeze" the mouse once it finds the color?
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim img As New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height) Dim gr As Graphics = Graphics.FromImage(img) gr.CopyFromScreen(New Point(0, 0), New Point(0, 0), New Size(img.Width, img.Height)) For c As Integer = 0 To img.Width - 1 For r As Integer = 0 To img.Height - 1 If img.GetPixel(c, r).ToArgb = Color.FromArgb(255, 255, 255).ToArgb Then Cursor.Position = New Point(c, r) Return End If Next Dim newMousePosition As New System.Drawing.Point newMousePosition.X = c System.Windows.Forms.Cursor.Position = newMousePosition Next End Sub End Class
This post has been edited by Iamazn: 17 September 2009 - 07:34 PM