Gordi300 Posted January 26, 2014 Share Posted January 26, 2014 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 More sharing options...
Richard Robertson Posted January 26, 2014 Share Posted January 26, 2014 (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 January 26, 2014 by Richard Robertson Link to comment Share on other sites More sharing options...
Gordi300 Posted January 26, 2014 Author Share Posted January 26, 2014 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 More sharing options...
Richard Robertson Posted January 27, 2014 Share Posted January 27, 2014 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. Link to comment Share on other sites More sharing options...
Gordi300 Posted January 27, 2014 Author Share Posted January 27, 2014 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 More sharing options...
Moderators Melba23 Posted January 27, 2014 Moderators Share Posted January 27, 2014 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. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts