Find pixel color on screen?
-
- User
- Posts: 78
- Joined: Sun Apr 24, 2005 3:22 am
Find pixel color on screen?
Hi, I was wondering how I would go about finding the pixel color of a pixel on the screen, and not just the window?
I know about GetPixel_, but I am unsure on the parameters for it.
I know about GetPixel_, but I am unsure on the parameters for it.
Re: Find pixel color on screen?
This is something I cut down from other examples in these forums... it shows
the color of the pixel under the mouse pointer when you run it. Maybe you
should stick it in a loop or something?
the color of the pixel under the mouse pointer when you run it. Maybe you
should stick it in a loop or something?

Code: Select all
dc=CreateDC_("DISPLAY",0,0,0) : GetCursorPos_(mouse.POINT)
p=GetPixel_(dc,mouse\x,mouse\y) : DeleteDC_(dc)
Debug "R="+Str(Red(p))+", G="+Str(Green(p))+", B="+Str(Blue(p))
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
-
- User
- Posts: 78
- Joined: Sun Apr 24, 2005 3:22 am
Hi roachofdeath,
Would a simplistic way work for you? Eg, do a screencapture (various code snippets in codearchive on www.purearea.net - windows-system and screenshots directory) and then get the point of the captured image?
Would a simplistic way work for you? Eg, do a screencapture (various code snippets in codearchive on www.purearea.net - windows-system and screenshots directory) and then get the point of the captured image?
@}--`--,-- A rose by any other name ..
-
- User
- Posts: 78
- Joined: Sun Apr 24, 2005 3:22 am
Hi PHP
But PB's example works
Here in a Repeat - ForEver Loop
With a 500 millisc. delay
Remember to kill the program from the editor as it run's forever
Best regrads
Henrik
But PB's example works
Here in a Repeat - ForEver Loop
With a 500 millisc. delay
Remember to kill the program from the editor as it run's forever
Code: Select all
Repeat
dc=CreateDC_("DISPLAY",0,0,0) : GetCursorPos_(mouse.POINT)
p=GetPixel_(dc,mouse\x,mouse\y) : DeleteDC_(dc)
Debug "R="+Str(Red(p))+", G="+Str(Green(p))+", B="+Str(Blue(p))
Delay (500)
ForEver
Henrik
Code: Select all
; Return the RGB color of the pixel at the specified coordinates
; or #CLR_INVALID (-1) if coordinates is outside the screen
ProcedureDLL GetPixelColor(x,y)
sysviewDC = GetDC_( hwndSysview )
ProcedureReturn GetPixel_( sysviewDC,x, y )
EndProcedure