Anyone know how to get the color of a pixel outside you'r FB app ?
As if the color of you'r background pic on you'r desktop is green then it returns green.
Or if i where to move a window over the cordinate where it's monitoring it would return a diffrent color.
Fetching the pixel color outside you'r app.
Got the answer from mysoft on irc:
Code: Select all
dim as hdc ScreenDC = GetDC(GetDesktopWindow())
dim as uinteger BGRA = GetPixel(ScreenDC,X,Y)
That post you just did contributed absolutly 0 to this or any other topic of this forum.Eponasoft wrote:By the way, it's "your", not "you'r".
Your = something that belongs to you, something that is yours.
You're = a short version of "you are".
"You're going home to your wife."
You'r wife/mommy must be proud.
-
- Site Admin
- Posts: 6323
- Joined: Jul 05, 2005 17:32
- Location: Manchester, Lancs
This doesn't seem to work .... (WinXP SP5) ....TbbW wrote:Got the answer from mysoft on irc:
Code: Select all
dim as hdc ScreenDC = GetDC(GetDesktopWindow()) dim as uinteger BGRA = GetPixel(ScreenDC,X,Y)
I get all the time : &hffffffff ... strange ...(it seems i'll have to use the classical method ... unless you come with some answer ....)
The desktop window is not the screen - it’s effectively the window that is below all of the other windows. Your GetPixel call is returning CLR_INVALID, indicating that the specified pixel is outside of the current clipping region, and as the code below shows, this is because the desktop window has an empty clipping region.
GetDesktopWindow
GetDC
GetPixel
GetClipBox
Code: Select all
#include "windows.bi"
dim as HDC hdcDesktop, hdcScreen
dim as COLORREF c
dim as RECT rc
hdcDesktop = GetDC( GetDesktopWindow() )
print "CLR_INVALID = "; hex(CLR_INVALID);"h"
if GetPixel(hdcDesktop,10,10) = CLR_INVALID then
print "pixel is outside of current clipping region"
end if
print "NULLREGION = "; NULLREGION
if GetClipBox( hdcDesktop, @rc ) = NULLREGION then
print "region is empty"
end if
print rc.left, rc.top, rc.right, rc.bottom
print
hdcScreen = GetDC(0)
print hex(GetPixel( hdcScreen, 10, 10 ));"h"
print "SIMPLEREGION = "; SIMPLEREGION
if GetClipBox( hdcScreen, @rc ) = SIMPLEREGION then
print "region is a single rectangle"
end if
print rc.left, rc.top, rc.right, rc.bottom
sleep
Code: Select all
CLR_INVALID = FFFFFFFFh
pixel is outside of current clipping region
NULLREGION = 1
region is empty
0 0 0 0
808080h
SIMPLEREGION = 2
region is a single rectangle
0 0 1280 1024
GetDC
GetPixel
GetClipBox