Getpixel help. Thanks.
I use visual basic.net 2003 and i would like to read the HEX pixel value of a pixel under my mouse anywhere on my computer (not just in my program). I did this is visual basic 6 but i can not do it in .net. I am using windows API but it will not read the colors at all. Can someone please give me an example of how to read the hex pixel color? I know it is simple, i just cant seem to do it. :( Thanks.
I really do not understand. Here are my declared functions form the windows API.
Declare Function GetPixel Lib "gdi32" Alias "GetPixel" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Here is the code i am using in a timer:
Dim screen As Long = GetDC(0)
Me.Text = Hex(GetPixel(screen, Cursor.Position.x, Cursor.Position.y))
It is like the GetPixel Command is doing nothing. When a set me.text to the screen = GetDC(0) a bunch of numbers keep flowing so it seems the GetDC is working. Why is GetPixel not working?
Declare Function GetPixel Lib "gdi32" Alias "GetPixel" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Here is the code i am using in a timer:
Dim screen As Long = GetDC(0)
Me.Text = Hex(GetPixel(screen, Cursor.Position.x, Cursor.Position.y))
It is like the GetPixel Command is doing nothing. When a set me.text to the screen = GetDC(0) a bunch of numbers keep flowing so it seems the GetDC is working. Why is GetPixel not working?
I have also tried using GetDesktopWindow and using the handel it returns in the GetDC() API. GetDC() still works but GetPixel seems to be not be doing anything.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement