1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#include <windows.h>
#include <cstdlib>
#include <iostream>
#include <tchar.h>
using namespace std;
int main()
{
int bez = 0, bez2 = 3;
int r, g, b;
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nCmdShow);
do
{
HWND hwnd = FindWindow(_T("MSPaintApp"), _T("Untitled - Paint"));
RECT rc;
GetClientRect(hwnd, &rc);
ClientToScreen(hwnd, reinterpret_cast<POINT*>(&rc.left));
ClientToScreen(hwnd, reinterpret_cast<POINT*>(&rc.right));
HDC hdc = GetDC(hwnd);
COLORREF pixel;
for (int y = 0; y < 600; y++) { //scans Y values (vertical)
for (int x = 0; x < 800; x++) { // scans X (horizantal)
pixel = GetPixel(hdc, x, y);
r = GetRValue(pixel);
g = GetGValue(pixel);
b = GetBValue(pixel);
ReleaseDC(0, hdc);
if (r == 0 && g == 0 && b == 255) //
{
MessageBox(NULL, "Testing", "Hi!", MB_OK);
//mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); // mouse click event
//Sleep(500);
bez >= bez2;
bez++;
if (bez == bez2) { break;}
}
}
}
} while (bez != bez2);
return 0;
}
|