From: N1ke!
Wouldn't it be smarter to use InvBox instead of X, Y?
From: Richard
Function IsItemSelected(ItemSlot : Integer; UpText : String) : Boolean;
Var TPA : Array of TPoint;
Box: TBox;
Begin
Box := InvBox(ItemSlot);
FindColorsTolerance(TPA, clWhite, Box.x1, Box.y1, Box.x2, Box.y2, 0);
If High(TPA) > -1 Then
MMouse(MiddleTPA(TPA).x, MiddleTPA(TPA).y, 1, 2)
Else Exit;
Result := IsUpText(UpText) And (Pos('->', rs_GetUpText) > 0)
End;
Makes more sense to use something like that. Nice idea :)
In made this function with the original intention of finding an object of which the cords of an object had been found before. So to find and Axe or something. I would use SRL's FindAxe procedure to get the x and y. Then use this in the other procedure, so they would inter-depend.
However, saying that, would it be wise to scrap that idea? Then use Richard's version. Or to loop through the InvBoxes, to find with range the x and y is in, then use the InvBox function. The main principle for this was that: the user did not know which InvBox it, the selected item, was in. Furthermore, another Idea popped into my head; that I rename IsItemSelected to IsItemSelectedEx, then make another procedure call IsItemSelected to use the 'Loop through InvBox idea' (Richard :))
Thanks, for commenting.
Rep+ to all!
Edit:
Function IsItemSelectedEx(ItemSlot : Integer; UpText : String) : Boolean;
Var TPA : Array of TPoint;
Box : TBox;
Begin
Box := InvBox(ItemSlot);
FindColorsTolerance(TPA, clWhite, Box.x1, Box.y1, Box.x2, Box.y2, 0);
If High(TPA) > -1 Then
MMouse(MiddleTPA(TPA).x, MiddleTPA(TPA).y, 1, 2)
Else Exit;
Result := IsUpText(UpText) And (Pos('->', rs_GetUpText) > 0)
End;
Function IsItemSelectedEx(Name : String) : Boolean;
Var I : Byte;
Begin
For I := 1 to 28 Do
Begin
Result := IsItemSelectedEx(I, Name);
If Result Then Break;
End;
End;
^That's what my latter idea would look like ^
EDIT2: Missed Hyper's comment, Hyper I would look into that, it could be easily incorporated into IsItemSelectedEx, with an extra parameter.