begin
//清除结果,如果成功找到了,则x,y为该颜色的坐标
x:=0;
y:=0;
//founed:=False;
//0-从左往右;1-从中心找;2-从上往下
DC := GetDC(HWND(nil));
case FangXiang of
0:begin
for i:=Top to Down do
begin
for j:=Left to Right do
begin
clr := GetPixel(DC,j,i);
tem:=ColorToRGB(clr)-Color;
if Likes=1 then
begin
if tem=0 then
begin
x:=j;
y:=i;
//添加找到后的操作
break;
end;
end
else
begin
if (tem>=-300) and (tem<= 300) then
begin
x:=j;
y:=i;
//添加找到后的操作
break;
end;
end;
if (x>0) and (y>0) then break;
end;
if (x>0) and (y>0) then break;
end;
end;
1:begin
fu:=1;
Cishu:=Round((Down-Top)/2);
//i=1;
// while i<Cishu do
for i:=1 to Cishu do
begin
for j:=Cishu+Top to Down do
begin
for z:=1 to 2 do
begin
for k:=Left to Right do
begin
clr := GetPixel(DC,k,j+i*fu);
tem:=ColorToRGB(clr)-Color;
{if (tem>=-300) and (tem<= 300) then
begin
x:=j;
y:=i;
//添加找到后的操作
end; }
if Likes=1 then
begin
if tem=0 then
begin
x:=j;
y:=i;
//添加找到后的操作
break;
end;
end
else
begin
if (tem>=-300) and (tem<= 300) then
begin
x:=j;
y:=i;
//添加找到后的操作
break;
end;
end;
fu:=fu*(-1);
if (x>0) and (y>0) then break;
end;
if (x>0) and (y>0) then break;
end;
if (x>0) and (y>0) then break;
end;
if (x>0) and (y>0) then break;
end;
end;
2:begin
for i:=Left to Right do
begin
for j:=Top to Down do
begin
clr := GetPixel(DC,j,i);
tem:=ColorToRGB(clr)-Color;
{
if (tem>=-300) and (tem<= 300) then
begin
x:=j;
y:=i;
//添加找到后的操作
end; }
if Likes=1 then
begin
if tem=0 then
begin
x:=j;
y:=i;
//添加找到后的操作
break;
end;
end
else
begin
if (tem>=-300) and (tem<= 300) then
begin
x:=j;
y:=i;
//添加找到后的操作
break;
end;
end;