Kevin
2013-07-15 14:13:09
This will accept a name and a quantity to search the bank for to withdraw. It also creates a temporary bitmap of the first item in the bank and waits for the search to load to completion prior to grabbing the new item. As a side-warning, because of that, it will fail to withdraw an item if it happens to be in the first bank slot.
procedure WithdrawDesignatedItemAndQuantity(name: String; quantity: integer);
var
tries, time, i, x, y, bmp: integer;
Acc: Extended;
found: boolean;
BankSlot: TBox;
Colors: TIntegerArray;
TPA: TPointArray;
begin
if(BankScreen)then
begin
BankSlot:= BankIndexToMSBox(1);
TPAFromBoxWrap(IntToBox(BankSlot.x1, BankSlot.y1, BankSlot.x1+29, BankSlot.y1+29), TPA);
GetColorsWrap(TPA, Colors);
OffsetTPA(TPA, IntToPoint(- (BankSlot.x1), - (BankSlot.y1)));
Bmp := BitmapFromString(30, 30, '');
FastSetPixels(bmp, TPA, Colors);
//Done creating bitmap of bankslot 1
SearchBank(name);
time:= GetSystemTime + 2500;
repeat
found:= FindDeformedBitmapToleranceIn(Bmp, X, Y, BankSlot.x1, BankSlot.y1, BankSlot.x1+29, BankSlot.y1+29, 0, 0, False, Acc);
wait(RandomRange(50,65));
until((GetSystemTime > time) or (not found));
FreeBitmap(Bmp);
if(found)then
Writeln('Did not find ' + name);
MouseBankSlot(1, mouse_right);
WaitOptionMulti(['w-'+inttostr(quantity), 'Withdraw-X', 'w-X', 'X'], 1500);
for x:=0 to 200 do
begin
wait(RandomRange(50,65));
if(InRange(CountColorTolerance(0, 250, 396, 307, 410, 1), 155, 165))then
Break;
end;
Wait(randomRange(50,100));
TypeSend(IntToStr(quantity));
end;
end;