• Log in or sign up for an account here: https://www.sythe.org/login

Mouse position rgb color?

kharg0

Active Member
Joined
Feb 25, 2007
Sythe Gold
0
Messages
131
I changed my code a lot so heres the new 1:

Code:
    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 Startbuttn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Start.Click
        Timer1.Start()
        Do Until MousePosition.X = Screen.PrimaryScreen.Bounds.X
            If PictureBox2.BackColor = PictureBox1.BackColor Then

            Else
                Cursor.Position = New Point(MousePosition.X + 1, MousePosition.Y)
            End If
        Loop
        If MousePosition.X = Screen.PrimaryScreen.Bounds.X Then
            Cursor.Position = New Point(MousePosition.X - Screen.PrimaryScreen.Bounds.Width, MousePosition.Y + 1)
        End If
        If MousePosition.Y = Screen.PrimaryScreen.Bounds.Y Then
            MsgBox("No location was found for your chosen color")
        End If
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        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)
        PictureBox2.BackColor = TempBitmap.GetPixel(System.Windows.Forms.Cursor.Position.X, System.Windows.Forms.Cursor.Position.Y)
    End Sub

    Private Sub Choosebuttn_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Choose.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)
    End Sub
 
Runescape Gamblingrunescape gambling
Back
Top