Support Forums
[Tut] Find color on screen | Good for beginner bots [VB.Net] - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Visual Basic and the .NET Framework (https://www.supportforums.net/forumdisplay.php?fid=19)
+---- Thread: [Tut] Find color on screen | Good for beginner bots [VB.Net] (/showthread.php?tid=11167)

Pages: 1 2


[Tut] Find color on screen | Good for beginner bots [VB.Net] - mmki - 08-11-2010

Finding and Clicking a color on you Screen
By MMKI


Hey guys
I posted this tut on HF a while ago. Thought i would post here also. Only thing i worry of is if there is a way easier way to do this
that i haven't found Tongue Please don't use the code without looking over it. Its to learn not to use.
It scans each pixel on the screen for a RGB color. In this case i'm using it to find the light red ball on a game on pool in the popular game website OMGPOP.
The color im using is 217, 59, 73 (light red)

Place a button on your form and double click it to edit its code
Code:
Dim screensize As Size = New Size(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
  Dim screenshot As New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
  Dim g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(screenshot)
  g.CopyFromScreen(New Point(0, 0), New Point(0, 0), screensize)

This code takes a screenshot of the screen at sets it to full size (you will not be able to see it) Its from this invisible screenshot that the program will find the color
Next add the following
Code:
Dim pointx As Integer = 1
Dim pointy As Integer = 1
Dim looking As Boolean = True

Just declaring some integers and a boolean we are about to use. pointx
and pointy are the pixel that the program will scan for the correct colored pixel
Now add
Code:
Try
    While looking = True
    Dim atpoint As Color = screenshot.GetPixel(pointx, pointy)
    Dim red As Color = Color.FromArgb(255, 217, 59, 73) 'light red ball colour

    If atpoint = red Then
    Cursor.Position = New Point(pointx, pointy)
    looking = False
    pointx = 1
    pointy = 1
    End If

    pointy = pointy + 1
    If pointy = My.Computer.Screen.Bounds.Height Then
    pointy = 0
    pointx = pointx + 1
    End If

    End While

This code starts at the first pixel (1, 1). Then continues to scan each pixel until
it reaches the correct colored pixel.

Dim red As Color = Color.FromArgb(255, 217, 59, 73) 'light red
It is with that line in the previous code that you choose what color you want to find. In my case light red (255, 217, 59, 73)

Next add:
Code:
Catch ex As Exception
    MsgBox("Cannot find Color", , "HELP")
  End Try
This ends our try. With it is a catch, meaning it will come up with the
error msgbox saying the color cannot be found.

[Image: 49026587.png]
You can see here, kinda, that my mouse has found the color ball i selected and moved the mouse there.

http://www.hackforums.net/showthread.php?tid=232812 < This tutorial, by hackurheart, tells you how to simulate a mouse click. Which will come in handy if your trying to make a bot with this method or something.

Thanks for reading Smile
Hope i helped some people Smile


RE: [Tut] Find color on screen | Good for beginner bots [VB.Net] - Fragma - 08-11-2010

Said it on HF and I'll say it again here, fantastic tutorial. I've been wondering how to do this for a long time but never actually gave it a shot.


RE: [Tut] Find color on screen | Good for beginner bots [VB.Net] - ElectricDreams - 08-11-2010

Very nice tutorial man! Well done and thank you.


RE: [Tut] Find color on screen | Good for beginner bots [VB.Net] - CATMAN - 08-11-2010

Awesome tutorial,thanks man.


RE: [Tut] Find color on screen | Good for beginner bots [VB.Net] - mmki - 08-12-2010

Thanks peeps Smile
Glad you liked it Smile


RE: [Tut] Find color on screen | Good for beginner bots [VB.Net] - Deities - 08-12-2010

saw this on hf and would like to say that its a great tutorial. well done and would like to see an advanced version for variable changes and colors on screen.


RE: [Tut] Find color on screen | Good for beginner bots [VB.Net] - Fragma - 08-12-2010

I've added this to my compilation thread. Hope you don't mind! :]


RE: [Tut] Find color on screen | Good for beginner bots [VB.Net] - .Nielz - 08-12-2010

Nice tutorial , but one think I don't understand .
Here you use 217 = red , 59 = green , 73 = blue. What means the 255 ?
Dim red As Color = Color.FromArgb(255, 217, 59, 73)


RE: [Tut] Find color on screen | Good for beginner bots [VB.Net] - wchar_t - 08-13-2010

Cool.

this is also how basic aimbots work.

Smile


RE: [Tut] Find color on screen | Good for beginner bots [VB.Net] - .Nielz - 08-15-2010

(08-13-2010, 12:17 AM)BlaiR Wrote: Cool.

this is also how basic aimbots work.

Smile

That are pixels bots . Bit slow and laggy though :p