For example, black is 0, how can I find out what number other colors are?
Printable View
For example, black is 0, how can I find out what number other colors are?
The Color structure has a ToArgb method that returns an Integer, i.e. 32-bit number. You can use the BitConverter class to break that into its alpha, red, green and blue components if desired. There is also a FromArgb method that will accept a single 32-bit value or four 8-bit values.
I don't consider forums to be the place to learn the basics of programming. There are plenty of beginner tutorials for that. When people post questions on forums I assume that they have already done the work required to cover the basics so, if I say "set this property", "call this method" or "handle this event", they know how set a property, call a method or handle an event. If you don't know how to do those things then I suggest that you start with a beginners tutorial and cover the basics first. Here's a good one:
http://www.homeandlearn.co.uk/net/vbnet.html
Assuming you know how to do those basics things, either now or after reading that, you can use the advice I've already provided, which is basically to call the ToArgb method on your Color value. That's how you get a 32-bit number that represents a colour. If that doesn't cover your particular situation then you will need to explain your particular situation, so that we can provide advice specific to that situation.
I did a google search and followed this tutorial
http://www.youtube.com/watch?v=7lO0JMWwa2Q
I still don't know how to find the 32bit value of a color i put my mouse over =/
You didn't say anything about putting your mouse over anything in any previous post. We can't read minds so you have to provide us with all the relevant information. I've explained how to get a 32-bit numerical representation of a Color value. I had no idea that that Color value had to be created based on where your mouse pointer was currently located. I could suggest one way that I know would work but I doubt that it's the most efficient, so I'll leave it up to someone else.
Please provide a FULL and CLEAR description of EXACTLY what you want in future and you'll save us and yourself a lot of time.
1. Use the Screen class to get the size of the desktop on the primary screen.
2. Create a Bitmap of that size.
3. Create a Graphics object from the Bitmap.
4. Call CopyFromScreen to copy the desktop to the Bitmap.
5. Use the Cursor class to get the current mouse pointer location.
6. Call GetPixel on the Bitmap to get the Color at that location.
Couldn't you just get the pixel under the mouse pointer, maybe something like...
Code:Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
Using bmp As New Bitmap(1, 1)
Using g As Graphics = Graphics.FromImage(bmp)
g.CopyFromScreen(MousePosition, Point.Empty, bmp.Size)
Dim c As Color = bmp.GetPixel(0, 0)
Debug.WriteLine(c)
End Using
End Using
End Sub
Ok, it worked and the number it gave me was
FFD4D0C8
Now, What is a code where when I press button5, the mouse looks for a color in a certain area, then clicks that color and when it presses that color is goes and finds a different color in a different area and then clicks that color. How can I do that?