Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › Visual Basic Programming › [Help]Detect a certain pixels color[Solved]

[Help]Detect a certain pixels color[Solved]

Posts 1–11 of 11 · Page 1 of 1
DE
Dead Bones Brook
[Help]Detect a certain pixels color[Solved]
How to detect a certain pixels color?
(if that pixel is that color, then ...)

Anyone?
#1 · 16y ago
Jason
Jason
Quote Originally Posted by Dead Bones Brook View Post
How to detect a certain pixels color?
(if that pixel is that color, then ...)

Anyone?
There's a thread a few pages back to do with a Guitar Hero bot and I explain a way to get the pixels color on the screen and compare it to a certain color, let me get the link for you.

http://www.mpgh.net/forum/33-visual-...-searcher.html

There you go, scroll down a bit and you'll find my post.
#2 · edited 16y ago · 16y ago
DE
Dead Bones Brook
Quote Originally Posted by J-Deezy View Post


There's a thread a few pages back to do with a Guitar Hero bot and I explain a way to get the pixels color on the screen and compare it to a certain color, let me get the link for you.

http://www.mpgh.net/forum/33-visual-...-searcher.html

There you go, scroll down a bit and you'll find my post.
I read it, but I don't get it, sorry.
#3 · 16y ago
Blubb1337
Blubb1337
Which part don't you get?
#4 · 16y ago
DE
Dead Bones Brook
The part where he tells me what to do.
#5 · 16y ago
Jason
Jason
Okay i'll go through each section in detail for you.

First step. declarations:

[php]
Private Declare Function GetPixel Lib "Gdi32.dll" (ByVal hdc As IntPtr, ByVal x As Integer, ByVal y As Integer) As Integer
Private Declare Function CreateDC Lib "Gdi32.dll" (ByVal driverName As String, ByVal deviceName As String, ByVal output As String, ByVal lpInitData As IntPtr) As IntPtr
Private Declare Function DeleteDC Lib "Gdi32.dll" (ByVal dc As IntPtr) As Boolean

Dim ScreenDC As IntPtr
[/php]

The GetPixel function gets the color of a pixel at the specified coordinates and stores it as an integer value. For this to work you need a device context ("ByVal hdc", in this case we use "ScreenDC" which we assign to the display of your monitor) It also needs an x and y coordinate to get the pixel from ("ByVal x As Integer, ByVal y As Integer")

CreateDC creates a device context and DeleteDC deletes the device context. We need to get the DC of the display so we can scan it. On closing the program we need to release the DC.

ScreenDC is a global variable of type "IntPtr", we'll assign this variable a value in the form_load event.

Okay now that's declarations out of the way, now we need to get that value for ScreenDC

[php]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ScreenDC = CreateDC("DISPLAY", Nothing, Nothing, CType(Nothing, IntPtr))
End Sub
[/php]

Essentially what this does is assign the variable "ScreenDC" the device context of the monitor's display ("CreateDC("DISPLAY".....)")

Okay now we've got the ScreenDC, yay! Before we continue we have to remember to release the DC on form close so add this before we forget!

[php]
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
DeleteDC(ScreenDC)
End Sub
[/php]

This will release the device context specified by the variable "ScreenDC"

Okay so we've got the ScreenDC, now we can set up a PixelScanner function, like so:

[php]
Function PixelScan(ByVal startX As Integer, ByVal startY As Integer, ByVal toX As Integer, ByVal toY As Integer, ByVal sColor As System.Drawing.Color)

Dim thisPixel As Integer
Dim PixelColor As System.Drawing.Color

For x As Integer = startX To toX
For y As Integer = startY To toY
thisPixel = GetPixel(ScreenDC, x, y)
PixelColor = ColorTranslator.FromOle(thisPixel)

If PixelColor = sColor Then
'do whatever you want when the color is found here.
End If

Next
Next

Return Nothing

End Function
[/php]

Okay basically what this is doing:

The function "PixelScan" accepts 5 arguments; "StartX", "StartY", "ToX", "ToY" and "sColor".

Envision the area you're scanning as a big box, specified by the "StartX", "StartY", "ToX", "ToY" variables. The StartX and StartY values tell the function what location to start the scan from (i.e putting 0 for both StartX and StartY will start the scan at the top left corner of your screen. Now you need to tell it where to stop scanning for both the X and Y coords, that pretty much sets up your box. Now for the last argument "sColor", this is the color we are going to compare each pixel to (i.e the color you are searching for)

Now for the main part of the function.

Basically, to break this down into English terminology:

For each value of X between the two coordinates of x specified by "StartX" and "ToX", get every Y coordinate specified between "StartY" and "ToY". Now you have 2 coordinates, x and y. Now we employ the "GetPixel" function to get the color at this x/y coordinate. Remember, GetPixel outputs an integer, not a System.Drawing.Color. This is why we use a ColorTranslator to translate this integer into a color we can compare with our argument "sColor".

Because this is a for/next it will continue until all the pixels are scanned. Basically you have your first "For/Next" which is the x values. Contained in this is the For/Next for y values. Basically what this is saying is, get an x value between "StartX" and "ToX", for this x value check every y value. Once that is complete the next x value will be chosen and the process will continue until all pixels in the area are scanned.

In that snippet i have included a
[php]
'do what you want to happen when the colors match here
[/php]

Basically I have said, if the color of the currently scanned pixel is the same as the color specified by the argument "sColor", do something.

Okay now all you need to do is scan.

The following snippet will scan your whole screen (remember, your screen resolution is the number of pixels across and up your monitor):

[php]
PixelScan(0, 0, My.Computer.Screen.WorkingArea.Width, My.Computer.Screen.WorkingArea.Height, Color.Blue)
[/php]

Basically this is saying start scanning at the point (0, 0) and continue the entire screen has been scanned, the color to compare to is the color blue, if this color is found the function will do whatever you've told it to do when this color is found. Note, you don't need to use "My.Computer.Screen.WorkingArea..." all the time, that's just a quick way to tell it to scan the entire width and height of your screen, you can specify exactly what section to scan by putting an integer value in there like :

[php]
PixelScan(100, 100, 200, 200, color.black)
[/php]

I hope this long ass post helps you out, took ages to type out haha.

Good luck.
#6 · edited 16y ago · 16y ago
NE
Newphag
Thank you,

is a lazy ass...so i have to do his work.
He wants me to make prog that finds pokemon for him.


It works somehow....but he says: can`t find CreateDC in DLL Gdi32.dll.
How i fix?
For the rest its works ok
#7 · edited 16y ago · 16y ago
Jason
Jason
Quote Originally Posted by Newphag View Post
Thank you,

is a lazy ass...so i have to do his work.
He wants me to make prog that finds pokemon for him.


It works somehow....but he says: can`t find CreateDC in DLL Gdi32.dll.
How i fix?
For the rest its works ok
There may be a problem with your Gdi32.dll...try this (add it above "Public Class Form1" or w/e)

[php]
Imports System.Runtime. InteropServices 'REMOVE THE SPACE, MPGH BLOCKS IT OTHERWISE
[/php]

Then put this with your other declarations (DeleteDC etc)

[php]
<DllImport("Gdi32.dll")> _
Public Shared Function CreateDC(ByVal driverName As String, ByVal deviceName As String, ByVal output As String, ByVal lpInitData As IntPtr) As IntPtr
End Function
[/php]
#8 · 16y ago
NE
Newphag
Okay thanks,
It works fine now.
#9 · 16y ago
Jason
Jason
Quote Originally Posted by Newphag View Post
Okay thanks,
It works fine now.
Okay good good.
#10 · 16y ago
DE
Dead Bones Brook
Quote Originally Posted by Newphag View Post
Thank you,

is a lazy ass...so i have to do his work.
He wants me to make prog that finds pokemon for him.


It works somehow....but he says: can`t find CreateDC in DLL Gdi32.dll.
How i fix?
For the rest its works ok
Hey, fuck you.
Glad it works though.


Thank you mr. helper, love you.
#11 · 16y ago
Posts 1–11 of 11 · Page 1 of 1

Post a Reply

Similar Threads

  • [Help] Changing Richtextbox's selection color. [solved]By alvaritos in Visual Basic Programming
    5Last post 15y ago
  • [Help]Form Background Color[Solved]By Shark23 in Visual Basic Programming
    5Last post 16y ago
  • [help]Convert String to Color[Solved]By mnpeepno2 in Visual Basic Programming
    10Last post 16y ago
  • [Help]Change Txt Colors[Solved]By ppl2pass in Visual Basic Programming
    4Last post 16y ago
  • [Help]Portions of Screen Flash Diff. Colors[SolvedBy Balls Out in Battlefield Bad Company 2 (BFBC2) Hacks
    7Last post 16y ago

Tags for this Thread

None