Sign in to follow this  
Followers 0
Gordi300

VB.NET (VB2010) - PixelGetColor

6 posts in this topic

Hi, I'm making a program to get the color of a pixel in the screen and I want to code:

If it's black (RGB 0,0,0) click that pixel and if it's red (RGB 255,0,0) press Esc. I was making the code but I get stuck when I have to say the color of the pixel. If you can help me or give me any advise I would be really greateful. I'm from Uruguay, my English is not the best, I wish you can understand me. TY

Code:

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
     AutoitCommand.PixelGetColor(100, 100)
        If PixelColorBlack Then                 'THIS IS WHAT I DON'T KNOW HOT TO CODE
            AutoitCommand.MouseClick("Left", 100, 100)
         ElseIf PixelColorRed Then          'THIS IS WHAT I DON'T KNOW HOT TO CODE
            AutoitCommand.Send("{Esc}")
        End If 
End Sub

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

There are a lot of ways to do it. The easiest is to get a reference to the device context for the desktop and copy the segment you care about to a local buffer you can read for color.

While I say easy, I mean that it's easy if you are already familiar with graphics in win32.

This is the function that will let you get the DC. http://msdn.microsoft.com/en-us/library/windows/desktop/dd144871%28v=vs.85%29.aspx

Edited by Richard Robertson

Share this post


Link to post
Share on other sites

I'm not so familiar with graphics in win32 but I can try. A friend told me that using AutoIt PixelGetColor was the easier way to make the program.
I want to take it from a game made in DirectX and AutoIt is very useful for this kind of games.

Do you have any idea of how it will be in VB.NET using AutoIt?

I was thinking about declaring the result of PixelGetColor(100, 100) in RGB. What dou u think about this?

Share this post


Link to post
Share on other sites

Ok, two things. First and more importantly, automation of games is strictly against the rules for the forum.

Second, images rendered on the graphics card (DirectX) instead of via standard win32 (GDI) means are much harder to pull images from and I'm not sure where to point you even if we could discuss this.

Share this post


Link to post
Share on other sites

Is for making automation in a game but only for educational use. This collects the rest of the dragons when you hit them and not to lose time collecting them. Is for everyone and I if you use it, you don't take any advantage, only you can play more time and have more fun. I don't see anything bad with that because is not for making a bot and take advantage, that is against the rules of the forum.

The only thing I need is how to declare the result of the PixelGetColor. Any ideas?

Share this post


Link to post
Share on other sites

Gordi300.

You might only want to use the code for "educational use" ;) and it might not be against the game rules, but it is most certainly against our Forum rules (there is also a link at bottom right of each page). Thread locked. :naughty:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0