Simba Code:
type
TSlotInterface = record
Bounds:Tbox;
EmptySlot:Integer;
end;
TOfferInterface = record
bounds:Tbox;
end;
TGrandExchange = Record
Offer:TOfferInterface;
Slot:TSlotInterface;
end;
var
GrandExchange:TGrandExchange;
function TGrandExchange.IsUp: Boolean;
var
ParentWidget, ChildWidget: TReflectWidget;
begin
ParentWidget.GetWidget(465, 2);
ChildWidget.GetChild(ParentWidget, 1);
if Pos('grand', LowerCase(ChildWidget.GetText)) then
Result:= true;
ChildWidget.Free;
ParentWidget.Free;
end;
function TOfferInterface.OfferScreen:Boolean;
var
a, b:TReflectWidget;
begin
if a.Exists(465, 2) then
begin
a.GetWidget(465, 2);
b.GetChild(a, 1);
if Pos('offer', LowerCase(b.gettext)) then
Result := True;
end;
a.free;
b.free;
end;
procedure TSlotInterface.ClickBuy(Slot:integer);
var
a, b:TReflectWidget;
begin
A.GetWidget(465, Slot+6);
B.GetChild(A, 0);
Reflect.Mouse.Move(Point(
RandomRange(b.GetBounds.X1, b.GetBounds.X2),
RandomRange(b.GetBounds.y1, b.GetBounds.y2)
), 0, 0);
Reflect.Mouse.Click(mouse_left);
Wait(RandomRange(400,750));
A.free;
B.free;
end;
procedure TSlotInterface.ClickSell(Slot:integer);
var
a, b:TReflectWidget;
begin
A.GetWidget(465, Slot+6);
B.GetChild(A, 1);
Reflect.Mouse.Move(Point(
RandomRange(b.GetBounds.X1, b.GetBounds.X2),
RandomRange(b.GetBounds.y1, b.GetBounds.y2)
), 0, 0);
Reflect.Mouse.Click(mouse_left);
A.free;
B.free;
end;
procedure TOfferInterface.ClickConfirm;
var
a, b:TReflectWidget;
begin
a.GetWidget(465, 24);
b.GetChild(a, 54);
Reflect.Mouse.Move(Point(
RandomRange(b.GetBounds.X1, b.GetBounds.X2),
RandomRange(b.GetBounds.y1, b.GetBounds.y2)
), 0, 0);
Reflect.Mouse.Click(mouse_left);
a.free;
b.free;
end;
procedure TOfferInterface.SetPrice(amount:string);
var
a, b:TReflectWidget;
begin
a.GetWidget(465, 24);
b.GetChild(a, 12);
Reflect.Mouse.Move(Point(
RandomRange(b.GetBounds.X1, b.GetBounds.X2),
RandomRange(b.GetBounds.y1, b.GetBounds.y2)
), 0, 0);
Reflect.Mouse.Click(mouse_left);
Wait(RandomRange(500, 1000));
Reflect.Keyboard.TypeSend(amount, true);
a.free;
b.free;
end;
procedure TOfferInterface.SetQuantity(amount:String);
var
a, b:TReflectWidget;
begin
a.GetWidget(465, 24);
b.GetChild(a, 7);
Reflect.Mouse.Move(Point(
RandomRange(b.GetBounds.X1, b.GetBounds.X2),
RandomRange(b.GetBounds.y1, b.GetBounds.y2)
), 0, 0);
Reflect.Mouse.Click(mouse_left);
Wait(RandomRange(500, 1000));
Reflect.Keyboard.TypeSend(amount, true);
a.free;
b.free;
end;
function TSlotInterface.OfferType(Slot: Integer):String;
var
a, b: TReflectWidget;
begin
a.GetWidget(465, (Slot+6));
b.GetChild(a, 16);
Result := b.GetText;
b.Free;
a.Free;
end;
function TSlotInterface.GetItemFromSlot(Slot:Integer):String;
var
a,b:TReflectWidget;
begin
a.GetWidget(465, Slot+6);
b.GetChild(a, 19);
Result:= b.GetText;
a.free;
b.free;
end;
function TOfferInterface.ItemPrice:Integer; //Returns the price of the item
var
a, b:TReflectWidget;
begin
a.GetWidget(465, 15);
b.GetChild(a, 25);
Result := StrToInt(replace(b.GetText, ',', '', [rfReplaceAll]));
a.free;
b.free;
end;
function TOfferInterface.AmountSold:String //Returns the total amount sold so far.
var
a, b:TReflectWidget;
c, d:String;
begin
a.GetWidget(465, 22);
b.GetChild(a, 1);
c := Between('sold', 'for', b.GetText);
d := Between('>', '<', c);
d := replace(d, ',', '', [rfReplaceAll]);
Result := d;
a.free;
b.free;
end;
function TOfferInterface.AmountBought:Integer;//Returns the total amount bought so far.
var
a, b:TReflectWidget;
c, d:String;
begin
a.GetWidget(465, 22);
b.Getchild(a, 1);
c:= Between('bought', 'price', b.GetText);
d:= Between('>','<', c);
Result := StrToInt(replace(d, ',', '', [rfReplaceAll]));
a.free;
b.free;
end;
function TOfferInterface.OfferItem:String; //Returns the item being being bought or sold in the offer screen.
var
a, b:TReflectWidget;
begin
a.GetWidget(465, 24);
b.GetChild(a, 25);
Result:= b.GetText;
a.free;
b.free;
end;
function TGrandExchange.Collect:Boolean;//Clicks the collect button on the GEInterface
var //NOT the collect boxes in the offer screen.
a,b:TReflectWidget;
begin
a.GetWidget(465, 6);
b.GetChild(a, 1);
if Pos('collect', Lowercase(b.GetText)) then
begin
Result:= true;
Reflect.Mouse.Move(Point(
RandomRange(b.GetBounds.X1, b.GetBounds.X2),
RandomRange(b.GetBounds.y1, b.GetBounds.y2)
), 0, 0);
Reflect.Mouse.Click(mouse_left);
end;
a.free;
b.free;
end;
function TOfferInterface.TotalPrice:String; //Returns the total that the items sold/bought for so far.
var
a, b:TReflectWidget;
c, d:String;
begin
a.GetWidget(465, 22);
b.Getchild(a, 1);
c:= Between('price', 'coins', b.GetText);
d:= Between('>','<', c);
Result := replace(d, ',', '', [rfReplaceAll]);
a.free;
b.free;
end;
function TSlotInterface.ClickEmptySlot(buy, sell:Boolean):Boolean;
var
a,b:TReflectWidget;
i:Integer;
begin
if a.Exists(465, i) then
for i:= 7 to 14 do
begin
a.GetWidget(465, i);
b.GetChild(a, 16);
if Pos('Empty', b.GetText) then
begin
if buy then
begin
TSlotInterface.ClickBuy(i-6);
Result:= True;
a.free;
b.free;
Exit;
end;
if sell then
begin
TSlotInterface.ClickSell(i-6);
Result:= True;
a.free;
b.free;
Exit;
end;
end
else
Continue;
end
end;
function TSlotInterface.FindEmpty:Integer;
var
a,b:TReflectWidget;
i:Integer;
begin
if a.Exists(465, i) then
for i:= 7 to 14 do
begin
a.GetWidget(465, i);
b.GetChild(a, 16);
if Pos('Empty', b.GetText) then
Result := i;
end
end;
function TGrandExchange.AbortSlot(Slot:integer):Boolean;
var
a, b:TReflectWidget;
begin
A.GetWidget(465, Slot+6);
B.GetChild(A, 2);
Reflect.Mouse.Move(Point(
RandomRange(b.GetBounds.X1, b.GetBounds.X2),
RandomRange(b.GetBounds.y1, b.GetBounds.y2)
), 0, 0);
Reflect.Mouse.Click(mouse_right);
Wait(RandomRange(254,653));
Result := Reflect.Text.ChooseOption('Abort offer');
Wait(RandomRange(340, 400));
self.Collect;
a.free;
b.free;
end;
procedure TOfferInterface.ClickChooseItem;
var
a,b:TReflectWidget;
p:TPoint;
begin
a.GetWidget(465, 24);
b.GetChild(a, 0);
p.x := RandomRange(b.GetBounds.X1, b.GetBounds.X2);
p.y := RandomRange(b.GetBounds.Y1, b.GetBounds.Y2);
Reflect.Mouse.Move(p, 0, 0);
Reflect.Mouse.Click(mouse_left);
a.free;
b.free;
end;
function TOfferInterface.IsSearch:Boolean;
var
a, b:TReflectWidget;
begin
a.GetWidget(162,38);
Result := a.HasChild;
end;
procedure TOfferInterface.Search(item:string);
var
a,b:TReflectWidget;
i:Integer;
t:TReflectTimer;
pt:TPoint;
begin
if not self.OfferScreen then
exit;
if not self.isSearch then
self.ClickChooseItem;
Wait(RandomRange(250, 650));
Reflect.KeyBoard.TypeSend(item);
Wait(RandomRange(250, 650));
a.GetWidget(162,38);
b.GetChild(a, 1);
pt.x := RandomRange(b.GetBounds.X1, b.GetBounds.X2);
pt.y := RandomRange(b.GetBounds.Y1, b.GetBounds.Y2);
Reflect.Mouse.Move(pt, 0, 0);
Reflect.Mouse.Click(mouse_left);
a.free;
b.free;
end;
function TOfferInterface.GetQuantity:Integer;
var
a,b:TReflectWidget;
s1,s2:String;
i:String;
begin
a.GetWidget(465, 15);
b.GetChild(a, 18);
s1 := replace(b.getText, ',','', [rfReplaceAll]);
Result := StrToInt(Trim(replace(b.getText, ',','', [rfReplaceAll])));
a.free;
b.free;
end;
function TOfferInterface.CompleteBuy:Boolean;
begin
Result := (self.GetQuantity = self.AmountBought);
end;
function TOfferInterface.CompleteSold:Boolean;
begin
Result := (StrToInt(self.AmountSold) = self.GetQuantity);
end;
function TofferInterface.OfferType:String;
var
a, b:TReflectWidget;
begin
a.GetWidget(465, 15);
b.GetChild(a, 4);
Result := b.getText;
a.free;
b.free;
end;
function TOfferInterface.Complete:Boolean;
begin
if (self.OfferType = 'Buy offer') then
Result := self.CompleteBuy;
if (self.offertype = 'Sell offer') then
Result := self.CompleteSold;
end;