从C中的全屏直接游戏中获取像素颜色

时间:2013-06-16 21:19:14

标签: c colors directx pixel

所以我试图从名为“Gunz”的游戏中获取鼠标位置的像素颜色......

据我所知,Gunz在DirectX上工作。

我尝试使用GDI在窗口模式下工作,我得到了像素颜色,

但是当我使用全屏DirectX时,我只得到白色,例如:

红色:255

绿色:255

蓝色:255


这是我的代码 -

#include <stdlib.h>
#include <stdio.h>
#include <windows.h>


int main(int argc, char** argv)
{

FARPROC pGetPixel;

HINSTANCE _hGDI = LoadLibrary("gdi32.dll");


while(1) {

if(_hGDI){
    pGetPixel = GetProcAddress(_hGDI, "GetPixel");
    HDC _hdc = GetDC(NULL);


if(_hdc){
    POINT _cursor;
    GetCursorPos(&_cursor);
    COLORREF _color = (*pGetPixel) (_hdc, _cursor.x, _cursor.y);
    int _red = GetRValue(_color);
    int _green = GetGValue(_color);
    int _blue = GetBValue(_color);

    printf("Cursor Pos: X: %d, Y: %d.\n", _cursor.x, _cursor.y);
    printf("Red: %d\n", _red);
    printf("Green: %d\n", _green);
    printf("Blue: %d\n", _blue);
    }
}
Sleep(1000);
}

FreeLibrary(_hGDI);

return 0;

}

0 个答案:

没有答案