PDA

Click to See Complete Forum and Search --> : finding colour under cursor


deadeye
Oct 21st, 2000, 02:58 AM
hiya all,

I would like to know how I would be able to find the colour that is underneath the cursor. eg same as in Photoshop where you can set a colour by putting your mouse over the colour you want.

But I want to be able to do this over the desktop and over other programs.

I have no idea on how to do this and any help would be most apreashiated.

Thanks

kedaman
Oct 21st, 2000, 04:36 AM
'Put all this in a module
Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Declare Function GetDesktopWindow Lib "user32" () As Long
Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Type POINTAPI
X As Long
Y As Long
End Type

Function coloratcursor() as long
Dim pa As POINTAPI
GetCursorPos pa
coloratcursor = GetPixel(GetWindowDC(GetDesktopWindow), pa.X, pa.Y)
End Function
OnColorClick 50, 100, vbYellow

And call Coloratcursor and it will return the color :)

deadeye
Oct 21st, 2000, 05:24 AM
thanks..

that is what i was after
:p