so ive got this function i wrote to do what autoits pixelsearch function would do basiclly and it is slow AF i mean several seconds to scan a small block...
would prefer it to be able to scan entire screen in under a second
heres what i have so far any help would be greatly appreciated (ps im real new with c++ and im sure my code is hideouse, no need to tell me about it
)
Code
#include <windows.h>
#include <stdio.h>
#include "resource.h"
#include <iostream>
using namespace std;
int H = 0; int V = 0;
int PCC;
int PixelSearch(int X1, int Y1, int X2, int Y2, int sR, int sG, int sB, int Variation) {
bool PZD = false;
for (int CX = X1; CX <= X2; CX++) {
for (int CY = Y1; CY <= Y2; CY++) {
HDC c = GetDC(0); COLORREF scolor = GetPixel(c,CX,CY); ReleaseDC(0,c);
DWORD cR = BYTE GetRValue(scolor); DWORD cG = BYTE GetGValue(scolor); DWORD cB = BYTE GetBValue(scolor);
if (((cR < (sR-Variation)) || (cR > (sR + Variation))) && ((cG<(sG-Variation)) || (cG>(sG + Variation))) &&
((cB < (sB - Variation)) || (cB > (sB + Variation)))) { }
else { PZD = true; }
}
}
return PZD;
}
int main() {
bool PSEARCH;
PSEARCH = PixelSearch(10,10,25,25,0,0,0,1);
if (PSEARCH == true) { cout << "Color Found" << endl; }
else { cout << "No Match" << endl; }
return 0;
}
This post was edited by Norax912 on Oct 27 2016 01:43am