Code:
#include <windows.h>
#pragma comment(lib, "gdi32.lib")
#pragma comment(lib, "user32.lib")
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE reserved, LPSTR lpCommand, INT nCmdShow)
{
MSG msg = { 0 };
HWND hwndEdit;
POINT pt;
HDC hdc;
COLORREF clr, clrOld = RGB(1,1,1);
TCHAR buf[100];
if (!(hdc = GetDC(NULL))) return -1;
if (!(hwndEdit = CreateWindowEx(0, TEXT("EDIT"), TEXT("ColorHack"),
WS_OVERLAPPEDWINDOW | WS_VISIBLE | ES_READONLY,
0, 0, 200, 90,
NULL, NULL, hInstance, NULL))) return -1;
SetWindowPos(hwndEdit, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
SetWindowText(hwndEdit, TEXT("Hold down H to activate!"));
while (TRUE)
{
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
if (!IsWindow(hwndEdit))
{
break;
}
if ((GetAsyncKeyState('H') & 0x8000) && GetCursorPos(&pt))
{
if ((clr = GetPixel(hdc, pt.x, pt.y)) != CLR_INVALID &&
clr != clrOld)
{
clrOld = clr;
wsprintf(buf, TEXT("%02x%02x%02x"),
GetRValue(clr), GetGValue(clr), GetBValue(clr));
SetWindowText(hwndEdit, buf);
}
}
Sleep(20);
}
return 0;
}