How can I find the colour of any pixel on the screen

你说的曾经没有我的故事 提交于 2019-12-11 03:57:02

问题


I usually program in VB6 but but I believe with that I might be restricted to details within the active form. I also have codegear 2009 with c++ and delphi, that I got from a mate but I only have a little experience with Delphi and none at all with c++ but at least I have them if one of those program need to be used to acheive what I'm trying to do. I want to be able to do something like

IF pixelVar(x,y) = 'Red' ( or 'RGBvalue or whatever the correct colour representation)
THEN
    do something
END IF

I want to write a program to keep poker hand statistics and want the program to run while Im playing in the poker client program, auto recognizing the cards by pixel colour and position and entering them into the database. I think that if I can get easy access to pixel info it wouldn't be too difficult working out patterns to identify the number and suit of cards. Any help would be enormous. Thanks.


回答1:


Use GetDC() with its hWnd parameter set to 0 to get an HDC handle for the screen, then use GetPixel() to get a COLORREF of the pixel at the desired screen coordinates, and then finally use GetRValue(), GetGValue(), and GetBValue() to split the COLORREF into its Red, Green, and Blue values.



来源:https://stackoverflow.com/questions/8482414/how-can-i-find-the-colour-of-any-pixel-on-the-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!