Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27474

VS 2010 Finding a Pixel and moving cursor to the color help please

$
0
0
Heyy uhmm so I'm making a program that will automate tasks for you base on colors. How do I make the mouse move to a certain color? For example my windows form loads a game in a webrowser form of the program. When it loads up, I would like to create a button, and then when you click on it, the program will search for the RGB colors or whatever, and then click on it.

Here is the code I have now, but I would like to know how to search for pixels, and how to move the mouse to the pixel:
Code:

Public Class Form1

    Public Const MOUSEEVENTF_LEFTDOWN = &H2
    Public Const MOUSEEVENTF_LEFTUP = &H4
    Private Const MOUSEEVENTF_RIGHTDOWN = &H8
    Private Const MOUSEEVENTF_RIGHTUP = &H10


    Declare Function apimouse_event Lib "user32.dll" Alias "mouse_event" (ByVal dwFlags As Int32, ByVal dX As Int32, ByVal dY As Int32, ByVal cButtons As Int32, ByVal dwExtraInfo As Int32) As Boolean

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Cursor.Position = Me.PointToScreen(New Point(Label1.Left, Label1.Top))
        Call apimouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
        Call apimouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
        System.Threading.Thread.Sleep(600)
        Cursor.Position = Me.PointToScreen(New Point(500, 600))
    End Sub

    Private Sub Form1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseEnter
        Cursor.Clip = Me.Bounds
    End Sub
End Class

So let's say the shovel on game had a certain RGB for brown and it was 67, 76, 67 then the mouse will go to the shovel and click on it.

Viewing all articles
Browse latest Browse all 27474