These functions will find various interfaces within the resize-able NXT client. I will add more if they are requested and I have the time.
Backpack
Requirements: The entire backpack is uncovered, all 28 slots are visible (i.e. no scrollbar), total width less than 1135.
function FindBackpack(out Bounds: TBox): Boolean;
Finds the backpack by searching for bitmaps, outputs the bounds as a TBox, and returns a Boolean.
Takes ~20 ms.
function LoadSlotBoxes(const Bounds: TBox; const FileName: String): TBoxArray;
Given the previously found bounds, returns a TBoxArray of the 28 slots by loading a preset from a text file, found here: Slots.txt
Note: these boxes are the correct visual bounds. If you want the correct clickable bounds, then shrink by 3 pixels.
Takes ~2 ms.
(you can ignore the Grid functions if using SRL-6)
Results (the exact bounds and slots found by the functions):Simba Code:
//https://github.com/SRL/SRL-6/blob/d5817b11a391940d12180740a914a4cf5d72b204/lib/utilities/math.simba#L59 function GridBox(Slot, Columns, Rows, w, h, DiffX, DiffY: Int32; StartPoint: TPoint): TBox; begin Result.x1 := (StartPoint.x + ((Slot mod Columns) * DiffX) - (w div 2)); Result.y1 := (StartPoint.y + ((Slot div Columns) * DiffY) - (h div 2)); Result.x2 := (Result.x1 + w); Result.y2 := (Result.y1 + h); end; function Grid(Columns, Rows, w, h, DiffX, DiffY: Int32; StarTPoint: TPoint): TBoxArray; var i: integer; begin SetLength(Result, (Columns * Rows)); for i := 0 to High(Result) do Result[i] := GridBox(i, Columns, Rows, w, h, DiffX, DiffY, StarTPoint); end; function FindBackpack(out Bounds: TBox): Boolean; const LINE_COLOR = 6247745; HEADER_COLOR = 332333; HEADER_TOL = 9; var i, j, x, y, w, h, CoinBMP, PackBMP, DownBMP, CloseBMP: Int32; TPA, TPA2: TPointArray; ATPA, ATPA2: T2DPointArray; begin GetClientDimensions(w, h); CoinBMP := BitmapFromString(9, 9, 'meJzrufGz58bPSbd/A1HNvgcO5fOU' + '0jvNeteaTdjSgyQ14+6/RY//S0TUaVcvBqLOq1+ACCIFZEy9/lEqr' + 'gMortu8zqF3mdOElUZNqx2m7M/bead48yUOs3TxoEagiFHVdKPKOc' + 'oFc4AqoxYc7T7/mtMyhc8pVzF7pm3fartJ64FqLHt3AqWAulgNooC' + 'ycskTgVqMaxZAdAENrNx5Ay6lVz0PKAg3sOHgPbiBQPdbTtkGdA/Q' + 'QIgzILokI9sAFPp7uw=='); PackBMP := BitmapFromString(10, 10, 'meJyTt26Vt261cGoBIgkVcyACcl' + 'VssyEImQ1EQFlRdV+gIJAEclkFlZDVAAUh4rxigUCGmIg0EwsvRAQ' + 'iBRQBsoNrVwDNgWhh5RcGGgLkArUAZeUyuor33oiacwziDIhFQDbQ' + 'HCBpWLpYVLXQOmQlxBnILgRygXpB9qoWQmThjgEioHa1hCKT7pUQq' + '5EVgJBqIVANUNbn0E02FVW4H4EBArQLiIDGAh0JFAQAJ5hHLw=='); DownBMP := BitmapFromString(10, 8, 'meJzLuP2r49ZnBgyQvuKaUc9Z51N' + 'fM6/+rL35qweMWs99Kdn1OHbtXbupF9kKDljvewNU4H/6R+QJEArc' + '9cF8znXlnnNcVUdYs3caLz1vtvkxUI3p7m9ApLbitVDneaAUR/YOj' + 'piFQCu0Z5zWX/nQeMtbo+1fgbKCjSd4inezxy2Fu0Fr+imgAu1Vr5' + 'Vn3UOTggDl7iNAKanuCzzJSzC9AAQKjXulyrcjiwAAiq5bTg=='); CloseBMP := BitmapFromString(10, 10, 'meJzj4PFh5U6GIDauLAiCcDnAUm' + 'y8NRyCzZgIqoW3Ju3YF5Os3eyCnUAEZAC5EFkWzmigrHbKzoyL/4D' + 'iQARhsPM1wWUhCkKP/QEiIAMoBRSBynKXANlyMdvsd/4GIiADoh4o' + 'xcIWBHSkaOB6jdW/xEI2AxGEAdQClxWe/J7HdwPIEO4SIAPIBQoCp' + 'VhYfBGeZYf6F8hgZU8HSnFymANJBAKrhyCgFAAg/Uys'); try if FindColors(TPA, LINE_COLOR, 0, 0, w-1, h-1) then begin ATPA := ClusterTPA(TPA, 1); for i := 0 to High(ATPA) do begin Bounds := GetTPABounds(ATPA[i]); if (Bounds.Y2 = Bounds.Y1) then begin Bounds.Y2 := Min(h-1, Bounds.Y2 + 35); if FindBitmapToleranceIn(CoinBMP, x, y, Bounds.X1, Bounds.Y1, Bounds.X2, Bounds.Y2, 0) then begin Bounds.X1 := Max(0, Bounds.X1 - 4); Bounds.X2 := Min(w-1, Bounds.X2 + 4); if FindBitmapIn(PackBMP, x, y, 0, 0, Bounds.X2, Bounds.Y2) then begin Bounds.Y1 := y + 15; end else if FindBitmapIn(CloseBMP, x, y, Bounds.X2 - 15, 0, Bounds.X2 + 5, Bounds.Y2 - 85) then begin Bounds.Y1 := y + 11; end else begin WriteLn('Backpack error: didn''t find Red X or Backpack bitmap.'); Exit; end; if FindBitmapToleranceIn(DownBMP, x, y, Bounds.X1, Bounds.Y1, Bounds.X2, Bounds.Y2, 5) then begin WriteLn('Backpack error: not all slots visible.'); Exit; end; Exit(True); end else begin WriteLn('Backpack error: didn''t find Coin bitmap.'); end; end; end; end; finally FreeBitmap(CoinBMP); FreeBitmap(PackBMP); FreeBitmap(DownBMP); FreeBitmap(CloseBMP); end; end; function LoadSlotBoxes(const Bounds: TBox; const FileName: String): TBoxArray; var i, Width, Cols, Rows, SpaceX: Int32; GridPoint: TPoint; SS: TStringArray; List: TStringList; begin Width := Bounds.X2 - Bounds.X1 + 1; Cols := 2 + (Width - 94) div 40; Rows := Ceil(28 / Cols); if (not FileExists(FileName)) then begin WriteLn('Backpack slots error: didn''t find Slots.txt'); Exit; end; List.Init(); try List.LoadFromFile(FileName); for i := 0 to (List.GetCount() - 1) do begin SS := Explode(#9, List.GetStrings(i)); if (Length(SS) <> 3) then begin WriteLn('Backpack slots error reading Slots.txt'); Exit; end; if SameText(IntToStr(Width), SS[0]) then begin GridPoint.X := Bounds.X1 + StrToInt(SS[1]) + 19; SpaceX := StrToInt(SS[2]); Break; end; end; finally List.Free(); end; if (SpaceX < 1) then begin WriteLn('Backpack slots error: didn''t Width in find Slots.txt'); Exit; end; GridPoint.Y := Bounds.Y1 + 6 + 16; Result := Grid(Cols, Rows, 37, 33, SpaceX, 36, GridPoint); SetLength(Result, 28); end;
Minimap
Requirements: Don't cover the corners of the minimap, other than that it should work anywhere at any size.
function FindMinimap(out Bounds: TBox): Boolean;
Finds the minimap by searching for bitmaps, outputs the bounds as a TBox, and returns a Boolean.
Takes ~20 ms.
Results (the exact bounds found by the function):Simba Code:
function FindMinimap(out Bounds: TBox): Boolean; var x, y, w, h, TP_BMP, LG_BMP: Int32; begin GetClientDimensions(w, h); TP_BMP := BitmapFromString(9, 9, 'meJw7u2JapmXM2ekzPt3dD0RHdq4E' + 'siEIKP5kx7yvl7YA2e2eBWX2qXAEFH9zbNX8kkygGjQEVD8rLj3e1' + 'B8ZQaT2T6yGcP21XH9//wpEyAog4nApCBuI4OJwKSclKwiCiwPZEC' + 'kraUNMqa+PLiMjAPyxc2A='); LG_BMP := BitmapFromString(10, 10, 'meJzza1uWtflq8c6baAgo6Ne2zG' + 'HuiczLP5rv/EJDQEGglGLvAesDr0QiJyEjk6kH3fb+UJl4WLhls+z' + 'aGxAkPvs4T8ZsIIPdu1Zlx1OgFFfdWsG1t4HiXGHTGOwLgAjIhZBA' + 'KYHCpWKzLwOVAdUzmMQCEZALIYFSsilL9LvPW02/BkSqVdt47fKAX' + 'AYtbyAJlJKPXqZYd4JBwRIZAc0BCgJlgS6UKNollr1aMHMpnASKAB' + 'FQCmgU0D1YEVAKAJUng5Y='); try if FindBitmap(TP_BMP, x, y) then begin Bounds.X1 := Max(0, x - 16); Bounds.Y2 := Min(h-1, y + 34); if FindBitmap(LG_BMP, x, y) then begin Bounds.X2 := Min(w-1, x + 10); Bounds.Y1 := Max(0, y + 11); Result := True; end; end; finally FreeBitmap(TP_BMP); FreeBitmap(LG_BMP); end; end;
Chatbox
Requirements: have "All Chat" as your first tab, don't hide the corners of the chatbox
function FindChatbox(out Bounds: TBox): Boolean;
Finds the chatbox by searching for bitmaps, outputs the bounds as a TBox, and returns a Boolean.
Takes ~60 ms.
Simba Code:
function FindChatbox(out Bounds: TBox): Boolean; var x, y, w, h, ChatBMP, DownBMP, GrayBMP, YellowBMP: Int32; begin GetClientDimensions(w, h); GrayBMP := BitmapFromString(8, 8, 'meJxjYICClt4JC5avgiOIYEVT6+S5' + 'CyCod9pMIAIKZpWWAxlA9cgoKjkNqBgT2bl6hMTEYyKgOUAp39BIT' + 'HGIFIQLNBaCYM5ElwIAmjFFZg=='); YellowBMP := BitmapFromString(8, 8, 'meJxjYIAC46XH9fa9gCOIoPySvRCu' + '/NbHEAQUlJ68AcIWWXcPjtjrVkIYHKvuIyPZxBmaHRcwEdAcoJR89' + 'WGl+jNo4nApiCwEwZzJIBQ7VaZoL1wKAHR0Tuo='); ChatBMP := BitmapFromString(9, 9, 'meJz7c6Xzz5XO7oZ4ICoqjrEpj1Wb' + 'WgNE0sle17cEAqXsJuewxhUBxYEMiBSbmz5QCqgeKAIUZ2gIVayKA' + 'up1cvdk0TS7lK1kVGeeGWsyq0gcSALNUUsoAiJmG3cgF0jyhCfaO5' + 'hCZIHauZoXsjiHARHQFubCLiACMoC6gGqAKoEGcjllAEXkMrqAKiE' + 'K5Gz8pRSEmdJcgbJAjUBlECuADKD5jGsrgSjZgN9QXwdoCFCxmJup' + 'jJIa0NlAcaBrAbHUTng='); DownBMP := BitmapFromString(10, 8, 'meJzLuP2r49ZnBgyQvuKaUc9Z51N' + 'fM6/+rL35qweMWs99Kdn1OHbtXbupF9kKDljvewNU4H/6R+QJEArc' + '9cF8znXlnnNcVUdYs3caLz1vtvkxUI3p7m9ApLbitVDneaAUR/YOj' + 'piFQCu0Z5zWX/nQeMtbo+1fgbKCjSd4inezxy2Fu0Fr+imgAu1Vr5' + 'Vn3UOTggDl7iNAKanuCzzJSzC9AAQKjXulyrcjiwAAiq5bTg=='); try if (FindBitmap(GrayBMP, x, y) or FindBitmap(YellowBMP, x, y)) then begin Bounds.X1 := Max(0, x - 6); Bounds.Y1 := y + 14; end else if FindBitmap(ChatBMP, x, y) then begin Bounds.X1 := Max(0, x - 20); Bounds.Y1 := y + 15; end else begin WriteLn('Chatbox error: didn''t find All Chat or Left Arrow'); Exit; end; if FindBitmapToleranceIn(DownBMP, x, y, Bounds.X1, Bounds.Y1, w-1, h-1, 9) then begin Bounds.X2 := Min(w-1, x + 16); Bounds.Y2 := Min(h-1, y + 35); Result := True; end else begin WriteLn('Chatbox error: didn''t find Down Arrow'); Exit; end; finally FreeBitmap(GrayBMP); FreeBitmap(YellowBMP); FreeBitmap(ChatBMP); FreeBitmap(DownBMP); end; end;
Results (the exact bounds found by the function):