Hey all, I'm looking for a way to be able to read the color data at say pixel (0,5) on the screen and check it's color. Is there a way to do this that isn't window dependent? and if not, how do you do it? Thanks, John
Hey all, I'm looking for a way to be able to read the color data at say pixel (0,5) on the screen and check it's color. Is there a way to do this that isn't window dependent? and if not, how do you do it? Thanks, John
My Favorite Programming Line:
Code:#define true ((rand() % 2) ? true : false)
Ok, I tried that, however I need to access the color of a pixel in a separate thread than the one that calls the function. Should I pass in HWND_TOPMOST for the hwnd parameter?
My Favorite Programming Line:
Code:#define true ((rand() % 2) ? true : false)
Give this a try with the code from your other post.
Code:__declspec(dllexport) LRESULT CALLBACK KeyboardEvent (int nCode, WPARAM wParam, LPARAM lParam) { MOUSEHOOKSTRUCT * pMouseStruct = (MOUSEHOOKSTRUCT *)lParam; if (pMouseStruct != NULL) printf("Mouse position X = %d Mouse Position Y = %d\n", pMouseStruct->pt.x,pMouseStruct->pt.y); HWND window = GetForegroundWindow(); HDC hDC = GetDC(window); COLORREF rgb = GetPixel(hDC, pMouseStruct->pt.x, pMouseStruct->pt.y); COLORREF red = GetRValue(rgb); COLORREF green = GetGValue(rgb); COLORREF blue = GetBValue(rgb); printf("%02X %02X %02X\n",red,green,blue); return CallNextHookEx(hMouseHook, nCode,wParam,lParam); }
Actually guys, thanks for the help, but I found out how to get the handle to the window I was targetting anyway. Thanks
My Favorite Programming Line:
Code:#define true ((rand() % 2) ? true : false)