grindisbest
2007-05-26 04:19:27
Here's a function I use in one of my scripts. Its much like Stupid3000s ChooseOption with a little extra. Read the comment in the script.
So what do you think?
function ChooseOptionWithBad(x, y: Integer; bad, txt: string): Boolean;
{
By Grindisbest, Credit to Stupid3000.
Thanks to Stupid3000, I've just edited it. Its much like the ChooseOption function expect it will
only choose option if the option it looks at doesn't contain a string (bad)
in it.
Example. You search for 'Trade' as the option and put 'with' as the bad string,
it will click on the first option that has 'Trade' in it as long as it doesn't
have 'with' in it, otherwise it will search on. If it doesn't find one it will
click Cancel.
}
var
a, b, x1, y1, x2, y2, FinalX, FinalY, LeftCorner, RightCorner: Integer;
Found: Boolean;
begin
LeftCorner := BitmapFromString(4, 4, 'z78DA33753135313137C5' +
'411A600064715CEA914500CACE13F0');
RightCorner := BitmapFromString(4, 4, 'z78DA33753135313137' +
'C5200D30002E35F8C501C9C013F0');
Found := False
if (FindBitmap(LeftCorner, x1, y1)) and (FindBitmap(RightCorner, x2, y2)) then
begin
repeat
if FindText(FinalX, FinalY, txt, upchars, x1, y1, x2, 502) and not FindText(a, b, bad, upchars, x1, FinalY, x2, FinalY+20) then
begin
Found := True;
end else
begin
y1:=y+10;
Found := False;
end;
until((not FindText(x, y, txt, upchars, x1, y1, x2, 502)) or Found);
if (FindText(x, y, 'Cancel', upchars, x1, y1, x2, 502)) and (not Found) then
Mouse(x + 9, y + 3, 2, 2, True);
if Found then
begin
Result := True;
Mouse(FinalX + Length(txt) * 3, FinalY + 3 + Random(3), 2, 2, True);
end;
end;
FreeBitmap(LeftCorner);
FreeBitmap(RightCorner);
end;
So what do you think?