Private Sub KryptonButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KryptonButton1.Click
timer1.start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If PictureBox2.BackColor = PictureBox1.BackColor Then
'What ever you want it to do
Else
Cursor.Position = New Point(MousePosition.X + 1, MousePosition.Y)
If MousePosition.X = Screen.PrimaryScreen.Bounds.Width Then
Cursor.Position = New Point(MousePosition.X - Screen.PrimaryScreen.Bounds.Width, MousePosition.Y + 1)
ElseIf MousePosition.Y = Screen.PrimaryScreen.Bounds.Height Then
MsgBox("The chose color was not found")
End If
End If
End Sub
Private Function findColor(ByVal Color As Color, ByVal Area As Rectangle) As Point
Dim AreaSize As Size = Area.Size
Dim TempBitmap As New Bitmap(AreaSize.Width, AreaSize.Height)
Graphics.FromImage(TempBitmap).CopyFromScreen(Area.Location, New Point(), AreaSize)
For x As Integer = 0 To Area.Height - 1
For y As Integer = 0 To Area.Width - 1
If TempBitmap.GetPixel(x, y) = Color Then Return New Point(Area.X + x, Area.Y + y)
Next
Next
Return New Point(-1, -1)
End Function
Private Sub KryptonButton2_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles KryptonButton2.MouseUp
Dim TempBitmap As New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
Graphics.FromImage(TempBitmap).CopyFromScreen(Screen.PrimaryScreen.Bounds.Location, New Point(), Screen.PrimaryScreen.Bounds.Size)
PictureBox1.BackColor = TempBitmap.GetPixel(System.Windows.Forms.Cursor.Position.X, System.Windows.Forms.Cursor.Position.Y)
KryptonButton1.Enabled = True
End Sub