Jump to content

VB.NET (VB2010) - PixelGetColor


Gordi300
 Share

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
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?

Link to comment
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?

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...