Just to give you an alternative to the way 14578 has posted, this one will find the door color and make a big ATPA out of it:
function FindDoor(Color, Tol, Min: Integer; Open: Boolean): Boolean;
var
ATPA: T2DPointArray;
TPA: TPointArray;
P: TPoint;
hATPA, i: Integer;
begin
Result := False;
FindColorsTolerance(TPA, Color, MSX1, MSY1, MSX2, MSY2, Tol);
if (Length(TPA) > Min) then
begin
ATPA := SplitTPAEx(TPA, 10, 20);
hATPA := High(ATPA);
for i := 0 to hATPA do
begin
P := MiddleTPA(ATPA[i]);
Mouse(P.x, P.y, 3, 3, mouse_move);
if WaitUptextMulti(['doo', 'oor'], 500) then
begin
if WaitUptext('pen', 250) then
begin
if Open then
begin
ClickMouse2(mouse_left);
while IsMoving do
Wait(500);
end;
Result := True;
Exit;
end else
begin
if not Open then
begin
ClickMouse2(mouse_left);
while IsMoving do
Wait(500);
end;
Result := True;
Exit;
end;
end;
end;
end;
end;
I suggestion using it with vars something like this:
if FindDoor(DoorColor, 5, 40, True) then
begin
// ...
end;
I don't know why you'd ever need to find a door and
close it, but hey I like to plan for everything :p