Hack Forums
[.NET] Click on certain color - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Click on certain color (/showthread.php?tid=4597609)



Click on certain color - KingDeath360 - Dec 22, 2014

If any of you remember the 'potnoodle pira pira' game/competition.
you click the potnoodles on the screen and it gets faster and faster and If you where in the top 10 on the games leader-board you would get a free potnoodle.

well heres my now old source code:
Code
Public Class Form1
    Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Short) As Integer
    Private WithEvents timer1 As New Windows.Forms.Timer
    Private WithEvents timer2 As New Windows.Forms.Timer
    Private WithEvents timer3 As New Windows.Forms.Timer
    Dim colorcodes As String() = {"Color [A=255, R=154, G=21, B=26]", "Color [A=255, R=150, G=19, B=24]", "Color [A=255, R=156, G=21, B=27]", "Color [A=255, R=152, G=20, B=26]", "Color [A=255, R=152, G=19, B=25]", "Color [A=255, R=153, G=21, B=25]", "Color [A=255, R=151, G=19, B=26]", "Color [A=255, R=161, G=23, B=29]", "Color [A=255, R=161, G=23, B=29]", "Color [A=255, R=149, G=19, B=24]", "Color [A=255, R=154, G=20, B=26]", "Color [A=255, R=154, G=21, B=26]"}
    Public Declare Sub mouse_click Lib "user32" Alias "mouse_event" (ByVal dwFlags As Short, ByVal dx As Short, ByVal dy As Short, ByVal cButtons As Short, ByVal dwExtraInfo As Short)
    Private Sub Timer2_Tick(ByVal sender As System.Object, _
                    ByVal e As System.EventArgs) Handles timer2.Tick

        Me.Text = Windows.Forms.Cursor.Position.X & " - " & Windows.Forms.Cursor.Position.Y & " (580 739)"


        Using bmp As New Bitmap(1, 1)
            Using g As Graphics = Graphics.FromImage(bmp)
                g.CopyFromScreen(Windows.Forms.Cursor.Position, _
                                          New Point(0, 0), New Size(1, 1))
            End Using
            Dim i As Integer = 0
            For i = 0 To colorcodes.Length - 1
                If bmp.GetPixel(0, 0).ToString = colorcodes(i) Then
                    mouse_click(mouseclicker.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
                    mouse_click(mouseclicker.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
                End If
            Next
        End Using

    End Sub
   Public Enum mouseclicker
        MOUSEEVENTF_LEFTDOWN = &H2
        MOUSEEVENTF_LEFTUP = &H4
    End Enum
    Private Sub Timer1_Tick(ByVal sender As System.Object, _
                    ByVal e As System.EventArgs) Handles timer1.Tick

        Using bmp As New Bitmap(1, 1)
            Using g As Graphics = Graphics.FromImage(bmp)
                g.CopyFromScreen(Windows.Forms.Cursor.Position, _
                                          New Point(0, 0), New Size(1, 1))
            End Using
            '   ListBox1.Items.Add(bmp.GetPixel(0, 0).ToString)
            If GetAsyncKeyState(1) Then
                ' MsgBox(bmp.GetPixel(0, 0).ToString & " - " & Windows.Forms.Cursor.Position.X & Windows.Forms.Cursor.Position.Y)
                ListBox1.Items.Add(bmp.GetPixel(0, 0).ToString)

            End If

        End Using
    End Sub
    Private Sub Timer3_Tick(ByVal sender As System.Object, _
                  ByVal e As System.EventArgs) Handles timer3.Tick

        Using bmp As New Bitmap(1, 1)
            Using g As Graphics = Graphics.FromImage(bmp)
                g.CopyFromScreen(Windows.Forms.Cursor.Position, _
                                          New Point(0, 0), New Size(1, 1))
            End Using
            Label2.Text = bmp.GetPixel(0, 0).ToString
          

        End Using
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Cursor.Position = New Point(580, 739)


        timer1.Interval = 10
        timer1.Start()

    End Sub

    Private Sub Form1_MouseClick(sender As Object, e As MouseEventArgs) Handles Me.MouseClick
        timer1.Stop()
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        timer2.Interval = 1
        timer2.Start()
        timer3.Interval = 1
        timer3.Start()
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

    End Sub
End Class