CynicRus
2012-06-23 07:19:10
Maybe this feature is already there, but I could not find it in the documentation - so I made ​​my version of this functional.
UPD: Some code fix.
//Watching at point P, if color in p was changed - then right click to point
function ClickOnColorChange(P: TPoint; WaitTime: integer): boolean;
var
x,y: integer;
ecolor,tempcolor: integer;//base color
endtime: integer;
begin
x:=P.x;
y:=P.y;
ecolor:=GetColor(x,y);
endtime:=GetSystemTime + WaitTime;
//watching
while (endtime > GetSystemTime) do
begin
tempcolor:=GetColor(x,y);
if ecolor<>tempcolor then
begin
MoveMouse(x,y);
ClickMouse(x, y, mouse_Right);
result:=true;
exit;
end;
end;
end;
//Watching at point P, if color defined as BaseColor in p was changed - then right click to point
function ClickOnColorChangeEx(P: TPoint; BaseColor: integer;WaitTime: integer): boolean;
var
x,y: integer;
tempcolor: integer;
endtime: integer;
begin
x:=P.x;
y:=P.y;
endtime:=GetSystemTime + WaitTime;
//watching
while (endtime > GetSystemTime) do
begin
tempcolor:=GetColor(x,y);
if BaseColor<>tempcolor then
begin
MoveMouse(x,y);
ClickMouse(x, y, mouse_Right);
result:=true;
exit;
end;
end;
end;
UPD: Some code fix.