SRL Archive - Research & Development Lounge

ChooseOption1


Nava2

2008-06-07 11:40:03

Well, I read someone posting about how they couldn't figure out how to bank by using ChooseOption because 'ank' is in all the names. So, as an alternative I editted the current procedure and added Line Picking! :) Now, the function will work as it used to, but also will work with a line number should you choose to use it.

Without further adieu:

{*******************************************************************************
function ChooseOption1(Option: variant): Boolean;
By: Wizzup? and Nava2
Description: Finds Popup menu, then clicks on it. Allows looking for text or
choosing an option line, first line is 1.
*******************************************************************************}

function ChooseOption1(Option: variant): Boolean;
var
B: TBox;
P: TPointArray;
X, Y, Z: Integer;

begin
GetClientDimensions(B.X2, B.Y2);
B.X1 := 0;
B.Y1 := 0;
FindColorsTolerance(P, 4674653, B.X1, B.Y1, B.X2, B.Y2, 0);
If Length(P) = 0 Then
Exit;
B := GetTPABounds(P);
case VarType(Option) of
3: begin
B := IntToBox(B.X1, B.Y1 + 19, B.X2, B.Y2)
Z := (B.Y2 - B.Y1) mod 15;
if InRange(Option, 0, Z) then
begin
Result := true;
Mouse(B.X1 + 5, B.Y1 + ((Option-1)*15) + 6, Random(B.X2 - B.X1), 6, True);
end else
SRL_Warn('ChooseOption1', 'Line chosen does not exist.', 1);
end;

256: If FindText(X, Y, option, upchars, B.X1, B.Y1, B.X2, B.Y2) Then
Begin
Result := True;
Mouse(B.X1 + 5, y + 1, Random(B.X2 - B.X1), random(13), True);
End
else
SRL_Warn('ChooseOption1', 'Invalid Variant Type Use only integers or strings!', 1);
end;

if not Result then
begin
MMouse(B.X1 - 50, B.Y1 - 50, 40, B.Y2 - B.Y1);
Wait(200 + Random(100));
end;
end;

Please post comments.

Nava2

Pietro

2008-06-07 16:30:52

this "someone" was me, and it was at IRC…
I used FindTextTpaEx to do it as a alternative.
Ty vm, i will test this function and if works, i will replace the TpaEx=)

XcanadamanX

2008-06-07 17:14:13

just wondering what if you lagg and get a different popup. it will still click the line but it wont be the right thing so it would screw up. why dont you add a text check thing in there so it checks if its the right text it is looking for?

The Claw

2008-06-07 22:25:52

ChooseOption('Bank quickly') ?

Pietro

2008-06-08 15:07:38

From: The Claw
ChooseOption('Bank quickly') ?


Isso Nom Ecxiste!!! (Padre Quevedo)

n3ss3s

2008-06-09 04:48:53

Well, you could choose 'ank' on a particular line, but you could aswell choose "ank anker" on any line! ;)


Experimental, a bit…

|
V


Function ChooseOptionMultiCustom(Texts: TStringArray): Boolean;

Var
TPA: TPointArray;
B: TBox;
I, C, X, Y: Integer;
Begin
GetClientDimensions(B.X2, B.Y2);
B.X1 := 0;
B.Y1 := 0;
FindColorsTolerance(TPA, 4674653, B.X1, B.Y1, B.X2, B.Y2, 0);
If GetArrayLength(TPA) < 1 Then
Begin
srl_Warn('ChooseOptionMultiCustom', 'Option window not open!', warn_Warning);
Exit;
End;
B := GetTPABounds(TPA);
FindColorsTolerance(TPA, 4674653, B.x1, B.y1 + 18, B.x2, B.y2, 0);
B := GetTPABounds(TPA);
For I := 0 To (B.y2 - B.y1) Div 13 Do
Begin
B.y1 := B.y1 + I * 13;
B.y2 := B.y2 + 13;
For C := 0 To High(Texts) Do
If Not FindText(X, Y, Texts[c], UpChars, B.x1, B.y1, B.x2, B.y2) Then
Break
Else
If C = High(Texts) Then Result := True;
If Result Then
Break;
End;
If Result Then
Mouse(X + 2, Y + 2, 2, 2, True);
End;

Nava2

2008-06-09 08:33:25

*Bends over to n3ss3s*

Nava2