Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pixel color of cursor
#1
Is there any way to get the pixel color of part of the cursor? I tried but it just picks up the color of the window that is underneath it. Thanks for the help.
#2
Function GetColorInCursor
Code:
Copy      Help
;/
function# x y [flags] ;;flags: 1 x y are relative to the hot spot

;Returns a color in the current cursor (mouse pointer).
;Returns -1 on failure.

;x, y - pixel coordinates relative to the top-left corner of the cursor. If flag 1 used - relative to the hot spot (which is at the mouse position) of the cursor.

;EXAMPLE
;rep
,;1
,;out "0x%X" GetColorInCursor(0 0 1) ;;color at the hot spot (mouse position)


__MemBmp mb; POINT p
if(!GetCursorBitmap(mb &p)) ret CLR_INVALID
if(flags&1) x+p.x; y+p.y
ret GetPixel(mb.dc x y)

Function GetCursorBitmap
Code:
Copy      Help
;/
function# __MemBmp&mb [POINT*hotspot]

;Gets memory bitmap of the current cursor (mouse pointer).
;Transparent parts will be white.
;Also can optionally get hotspot position within the cursor.
;Returns cursor handle on success, 0 on failure.


CURSORINFO ci.cbSize=sizeof(CURSORINFO)
if(!GetCursorInfo(&ci)) ret

if(hotspot)
,ICONINFO ii
,if(!GetIconInfo(ci.hCursor &ii)) ret
,DeleteObject ii.hbmMask
,DeleteObject ii.hbmColor
,hotspot.x=ii.xHotspot; hotspot.y=ii.yHotspot
,

mb.Create(32 32)
RECT r.right=32; r.bottom=32; FillRect mb.dc &r GetStockObject(WHITE_BRUSH)
if(!DrawIconEx(mb.dc 0 0 ci.hCursor 32 32 0 0 DI_NORMAL)) ret
ret ci.hCursor
#3
Thank you Gintaras! Just what I wanted. Big Grin


Forum Jump:


Users browsing this thread: 1 Guest(s)