Wizzup?
2008-07-13 13:15:39
function ChooseOption(txt: string): Boolean;
var
B: TBox;
TPA: TPointArray;
X, Y, I, C: Integer;
P: TPoint;
begin
Result := False;
GetClientDimensions(B.X2, B.Y2);
B.X1 := 0;
B.Y1 := 0;
FindColorsTolerance(TPA, 4674653, B.X1, B.Y1, B.X2, B.Y2, 0);
If Length(TPA) < 10 Then
Exit;
B.X2 := 0;
B.Y2 := 0;
P := TPA[0];
For I := 0 To High(TPA) - 1 Do
If TPA[I].X = TPA[I+1].X - 1 Then
Begin
If C > 5 Then
Begin
B.X1 := P.X;
B.Y1 := P.Y;
Break;
End Else
C := C + 1;
End
Else
Begin
P := TPA[I + 1];
C := 0;
End;
If I = Length(TPA) Then
Begin
WriteLn('Choose Option Menu Getting Failed');
Exit;
End;
InvertTPA(TPA);
C := 0;
P := TPA[0];
For I := 0 To High(TPA) - 1 Do
If TPA[I].X = TPA[I+1].X + 1 Then
Begin
If C > 5 Then
Begin
B.X2 := P.X;
B.Y2 := P.Y;
Break;
End Else
C := C + 1;
End Else
Begin
P := TPA[I + 1];
C := 0;
End;
If I = Length(TPA) Then
Begin
WriteLn('Choose Option Menu Getting Failed');
Exit;
End;
If FindText(X, Y, txt, upchars, B.X1, B.Y1, B.X2, B.Y2) Then
Begin
Result := True;
Mouse(B.X1 + 5, y + 1, B.X2 - B.X1 - 5, 13, True);
End
Else
begin
MMouse(B.X1 - 50, B.Y1 - 50, 40, B.Y2 - B.Y1);
Wait(200 + Random(100));
end;
end;:)
The bug:
[banana]Color Picked: 4674653 at (0, 338)
Color Picked: 4674653 at (518, 338)[/banana]
Those pixels are at first clBlack (0), but change after a few minutes of playing to the ChooseOption color.