the point of my code is for me to press f1 and it will scan 500 pixels down and 500 pixels and put them in a array (it just takes a box that is 500 by 500 of the screen). then after that when i hit end it will click on only on the color black or... what i set it to. anyway it has been doing odd stuff and i can't find why:
#include <iostream>
#include <windows.h>
using namespace std;
COLORREF rgb[499][499];
HDC hDC = GetDC(HWND_DESKTOP);
POINT main_coner;
BYTE rVal;
BYTE gVal;
BYTE bVal;
int red;
int green;
int blue;
int ff = 0;
int main()
{
for(;;)
{
if(GetAsyncKeyState(VK_F1))
{
cout << "started";
int a1 = 0;
int a2 = 0;
GetCursorPos(&main_coner);
int x = main_coner.x;
int y = main_coner.y;
for(;;)
{
//cout << a1 << "___" << a2 << "\n";
rgb[a1][a2] = GetPixel(hDC, x, y);
a1++;
x++;
if(x > main_coner.x + 499)
{
y++;
x = main_coner.x;
a1 = 0;
a2++;
}
if(y > main_coner.y + 499)
{
ff = 1;
break;
}
}
cout << "done";
break;
}
if(ff == 1)
break;
}
for(;;)
{
if(GetAsyncKeyState(VK_END))
{
GetCursorPos(&main_coner);
int x = main_coner.x;
int y = main_coner.y;
int a1 = -1;
int a2 = -1;
for(;;)
{
x++;
a1++;
rVal = GetRValue(rgb[a1][a2]);
gVal = GetGValue(rgb[a1][a2]);
bVal = GetBValue(rgb[a1][a2]);
red = (int)rVal; // get the colors into __int8
green = (int)gVal; // get the colors into __int8
blue = (int)bVal; // get the colors into __int8
if(red == 0 && green == 0 && blue == 0)
{
SetCursorPos(main_coner.x + x, main_coner.y + y);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
Sleep(10);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
Sleep(100);
}
if(x > main_coner.x + 499)
{
a1 = 0;
a2++;
}
if(y > main_coner.y + 499)
{
Sleep(100000000000);
break;
}
if(GetAsyncKeyState(VK_CONTROL))
{
Sleep(100000);
break;
}
}
}
}
for(;;)
{
if(GetAsyncKeyState(VK_END))
{
break;
}
}
return 0;
}
anyone see what's wrong with my code :( (feel free to add tags)