I’ve been working on this script all day and I finely got it working but has some problems still
What the script does is searches for a pixel inside of x1 y1 x2 y2 bye its color.
Ok here’s my problem I wonted to see how fast it worked so I had the mouse fallow each pixel it was checking. And I realized that it starts off searching really fast but slows way way way way down if you have it searching inside of a 100 by 100 pixel area.
Why is this slowing down and how can I fix it? Also if you guys have any suggestions on making it faster besides the problem I’m having let me know : ) thanks
Code:
#include <iostream>
#include <stdlib.h>
#include <windows.h>
int main()
{
cout << "pick a color" << endl;
system("pause");
POINT pt;
GetCursorPos(&pt);
HDC hdc = GetDC(NULL);
DWORD color = GetPixel(hdc, pt.x, pt.y);
unsigned int r = GetRValue(color);
unsigned int g = GetGValue(color);
unsigned int b = GetBValue(color);
cout << "red: " << r << endl;
cout << "green: " << g << endl;
cout << "blue: " << b << endl;
int XL, YL, xcount, ycount, TLXBackup;
cout << "Top Left" << endl;
system("pause");
POINT TL;
GetCursorPos(&TL);
cout << "Bottem Right" << endl;
system("pause");
POINT BR;
GetCursorPos(&BR);
TLXBackup = TL.x;
XL = BR.x - TL.x; // x2 x1
YL = BR.y - TL.y; // y2 y1
xcount = 0;
ycount = 0;
POINT TR;
Loop:
HDC hdc2 = GetDC(NULL);
DWORD color2 = GetPixel(hdc2, TL.x, TL.y);
unsigned int R = GetRValue(color2);
unsigned int G = GetGValue(color2);
unsigned int B = GetBValue(color2);
//cout << "RED: " << R << endl;
//cout << "GREEN: " << G << endl;
//cout << "BLUE: " << B << endl;
//cout << " xcount " << xcount << endl;
//cout << " ycount " << ycount << endl;
//cout << "x " << TL.x <<endl;
//cout << "y " << TL.y <<endl;
SetCursorPos(TL.x,TL.y);
if (( r == 255) && ( g == 255 ) && ( b == 255 ))
system("pause");
if (( r == R) && ( g == G ) && ( b == B ))
{
ending:
cout << TL.x << endl;
cout << TL.y << endl;
SetCursorPos(TL.x,TL.y);
cout << "color found" << endl;
cout << "RED: " << R << endl;
cout << "GREEN: " << G << endl;
cout << "BLUE: " << B << endl;
cin.get();
cin.ignore();
return 0;
}
if ( xcount == XL)
{
TL.y++;
TL.x = TLXBackup;
ycount++;
xcount = 0;
}
if ( ycount == YL )
{
goto ending;
}
xcount++;
TL.x++;
goto Loop;
}