program MyMouse;
{.include srl/srl.scar}
function GetChooseOptionMultiExPosition(Texts: TStringArray; TextType: String): TBox;
var
B: TBox;
TPA, TextTPA: TPointArray;
aTPA: T2DPointArray;
I, C, H, HH, ii, L: Integer;
P: TPoint;
Occurances: array [0..4] of TPointArray;
Colors: TIntegerArray;
begin
GetClientDimensions(B.X2, B.Y2);
B.X1 := 0;
B.Y1 := 0;
SetLength(aTPA, 2);
FindColorsTolerance(aTPA[0], 4409686, B.X1, B.Y1, B.X2, B.Y2, 0);
FindColorsTolerance(aTPA[1], 4016722, B.X1, B.Y1, B.X2, B.Y2, 0);
TPA := MergeATPA(aTPA);
SetLength(aTPA, 0);
If Length(TPA) < 10 Then
Exit;
B.X2 := 0;
B.Y2 := 0;
P := TPA[0];
H := High(TPA);
Dec(H);
For I := 0 To H 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];
H := High(TPA);
Dec(H);
For I := 0 To H 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;
TPA := [];
Colors := [13034990, 4231423, 2070783, 65535, 16776960, 9812166];
TextType := LowerCase(TextType);
case TextType of
'action', 'player': begin
FindColorsTolerance(Occurances[0], Colors[0], B.x1, B.y1, B.x2, B.y2, 3);
FindColorsTolerance(Occurances[1], Colors[5], B.x1, B.y1, B.x2, B.y2, 3);
end;
'item' : begin
FindColorsTolerance(Occurances[1], Colors[1], B.x1, B.y1, B.x2, B.y2, 3);
FindColorsTolerance(Occurances[2], Colors[2], B.x1, B.y1, B.x2, B.y2, 3);
end;
'npc' : FindColorsTolerance(Occurances[3], Colors[3], B.x1, B.y1, B.x2, B.y2, 3);
'object': FindColorsTolerance(Occurances[4], Colors[4], B.x1, B.y1, B.x2, B.y2, 3);
else
begin
FindColorsTolerance(Occurances[0], 1845035, B.X1, B.Y1, B.X2, B.Y2, 0);
FindColorsTolerance(Occurances[1], clBlack, B.X1, B.Y1, B.X2, B.Y2, 0);
FindColorsTolerance(Occurances[2], 6121839, B.X1, B.Y1, B.X2, B.Y2, 0);
TPA := MergeATPA(Occurances);
ClearDoubleTPA(TPA);
TPA := ReturnPointsNotInTPA(TPA, B);
end;
end;
if High(TPA) < 1 then TPA := MergeATPA(Occurances);
aTPA := SplitTPAEx(TPA, 7, 1);
SortATPAFromFirstPoint(aTPA, Point(B.x1, B.y1));
H := High(Texts);
L := High(aTPA);
For I :=0 To H do
begin
TextTPA := LoadTextTPA(Texts[i], UpChars, HH);
for ii := 0 to L do
If FindTextTPAInTPA(HH, TextTPA, aTPA[ii], TPA) Then
Begin
Result := IntToBox(B.x1 + 5, TPA[0].Y, B.x2 - 5, TPA[0].Y + 5);
Writeln('B.x1 + 5 = '+inttostr(B.x1 + 5));
Writeln('B.x2 - 5 = '+inttostr(B.x2 - 5));
Writeln('TPA[0].Y = '+inttostr(TPA[0].Y));
Writeln('TPA[0].Y + 5 = '+inttostr(TPA[0].Y + 5));
Exit;
End;
end;
MMouse(B.X1 - 50, B.Y1 - 50, 40, B.Y2 - B.Y1);
Wait(200 + Random(100));
end;
function P_ChooseOption( option : string): Boolean;
var
theBox : TBox;
begin
TheBox := GetChooseOptionMultiExPosition([option],'all');
case random(20) of
0: begin
MouseBox( TheBox.x1, TheBox.y1 + 9, TheBox.x2, TheBox.y2 + 9, 1); // too far down
Result := False;
end;
1: begin
MouseBox( TheBox.x1, TheBox.y1 - 9, TheBox.x2, TheBox.y2 - 9, 1); // too far up
Result := False;
end;
2..19: begin
Result := True;
MouseBox( TheBox.x1, TheBox.y1, TheBox.x2, TheBox.y2, 1); // clicks properly
end;
end;
end;
begin
MouseSpeed := 15;
Mouse( msx1+200, msy1+150, 0, 0, false);
wait(500);
while not P_ChooseOption('alk') do
begin
Mouse( msx1+200, msy1+150, 0, 0, false);
Wait(500);
end;
end.
guess it can be combined into:
program MyMouse;
{.include srl/srl.scar}
function P_ChooseOptionMulti( texts : TstringArray; Debug : Boolean): Boolean;
var
theBox : TBox;
B: TBox;
TPA, TextTPA: TPointArray;
aTPA: T2DPointArray;
I, C, H, HH, ii, L: Integer;
P: TPoint;
Occurances: array [0..4] of TPointArray;
Colors: TIntegerArray;
begin
GetClientDimensions(B.X2, B.Y2);
B.X1 := 0;
B.Y1 := 0;
SetLength(aTPA, 2);
FindColorsTolerance(aTPA[0], 4409686, B.X1, B.Y1, B.X2, B.Y2, 0);
FindColorsTolerance(aTPA[1], 4016722, B.X1, B.Y1, B.X2, B.Y2, 0);
TPA := MergeATPA(aTPA);
SetLength(aTPA, 0);
If Length(TPA) < 10 Then
Exit;
B.X2 := 0;
B.Y2 := 0;
P := TPA[0];
H := High(TPA);
Dec(H);
For I := 0 To H 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];
H := High(TPA);
Dec(H);
For I := 0 To H 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;
TPA := [];
Colors := [13034990, 4231423, 2070783, 65535, 16776960, 9812166];
FindColorsTolerance(Occurances[0], 1845035, B.X1, B.Y1, B.X2, B.Y2, 0);
FindColorsTolerance(Occurances[1], clBlack, B.X1, B.Y1, B.X2, B.Y2, 0);
FindColorsTolerance(Occurances[2], 6121839, B.X1, B.Y1, B.X2, B.Y2, 0);
TPA := MergeATPA(Occurances);
ClearDoubleTPA(TPA);
TPA := ReturnPointsNotInTPA(TPA, B);
if High(TPA) < 1 then TPA := MergeATPA(Occurances);
aTPA := SplitTPAEx(TPA, 7, 1);
SortATPAFromFirstPoint(aTPA, Point(B.x1, B.y1));
H := High(Texts);
L := High(aTPA);
For I :=0 To H do
begin
TextTPA := LoadTextTPA(Texts[i], UpChars, HH);
for ii := 0 to L do
If FindTextTPAInTPA(HH, TextTPA, aTPA[ii], TPA) Then
Begin
TheBox := IntToBox(B.x1 + 5, TPA[0].Y, B.x2 - 5, TPA[0].Y + 5);
if Debug then
begin
Writeln('B.x1 + 5 = '+inttostr(B.x1 + 5));
Writeln('B.x2 - 5 = '+inttostr(B.x2 - 5));
Writeln('TPA[0].Y = '+inttostr(TPA[0].Y));
Writeln('TPA[0].Y + 5 = '+inttostr(TPA[0].Y + 5));
end;
Wait(200 + Random(100));
case random(20) of
0: begin
MouseBox( TheBox.x1, TheBox.y1 + 9, TheBox.x2, TheBox.y2 + 9, 1); // too far down
Result := False;
Exit;
end;
1: begin
MouseBox( TheBox.x1, TheBox.y1 - 9, TheBox.x2, TheBox.y2 - 9, 1); // too far up
Result := False;
Exit;
end;
2..19: begin
Result := True;
MouseBox( TheBox.x1, TheBox.y1, TheBox.x2, TheBox.y2, 1); // clicks properly
Exit;
end;
end;
end;
end;
MMouse(B.X1 - 50, B.Y1 - 50, 40, B.Y2 - B.Y1);
end;
function P_ChooseOption( Option : string): Boolean;
begin
Result := P_ChooseOptionMulti( [option], True );
end;
begin
MouseSpeed := 15;
Mouse( msx1+200, msy1+150, 0, 0, false);
wait(200);
while not P_ChooseOption('alk') do
begin
Mouse( msx1+200, msy1+150, 0, 0, false);
Wait(200);
end;
end.
I personally like the second one more for usage, but the first one is easier to play around with…
Credits, of course, go to Wizzup?, Nava2, and N1ke! for developing ChooseOptionMultiEx, which this function is based on. :D